Jump to:
| Project: | Media Mover |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
hi,
a background on my situation. i've got tens of thousands of nodes with audio and video in my system, and am harvesting from CCK and transcoding to another CCK field.
here's a problem i describe vaguely, hope it's enough to give you the idea of what's wrong. suppose i've got a configuration which limits processing, storage, and complete stages to 1 (or X) files at a time. so... if you click "Run" from the configuration page it should only run one file, right? well, not necessarily if the auto-run on node insert/update is turned on. for example, if you complete into a CCK field, then that will call node_save(), right? with auto-run on, this will in turn trigger a call to media_mover_api_run_config() in the code below, with $nid specified.
the problem arises in the loop when $verb = anything but harvest. then media mover will just go on ahead and process, store, and complete another file. and when it completes the last file, updating a CCK node and saving the result, media_mover_api_run_config will be called yet again. the process goes on and on and on and on, and eventually your server will time out.
edward
<?php
function media_mover_api_run_config($config, $debug = true, $nid = null, $cron = false) {
$output = t('Running') .' '. l($config->name, 'admin/build/media_mover/config/'. $config->cid .'/view') ."<br />";
/**
* first, lock config, harvest files, store files, unlock config
* get all files ready for processing, process one file at a time
* lock each file to prevent overrunning
*/
// check to make sure that we have all directories
media_mover_api_check_config_dirs($config);
// start the loop where we run all the verbs
foreach (media_mover_api_verbs() as $verb) {
// we make a special case for harvesting
// @ TODO refactor harvest to work the same way that all the other steps do.
if ($verb == 'harvest') {
$output = media_mover_api_run_config_harvest($config, $verb, $nid);
}
else {
// -----------------------------------------------------
// run all the other configuration actions
// pass back the status of the previous step to get the previous files
$output .= media_mover_api_run_config_verb($config, $verb, media_mover_api_verb_base_status($verb), $cron);
}
} // end verb loop
// if in debug mode.....
if ($debug) {
return $output;
}
}
?>
Comments
#1
Can you describe the configuration you're using? Sounds like auto run needs a static $control var to prevent multiple runs.
#2
Can you give this a try and let me know if it works for you?
<?php/**
* Implementation of hook_nodeapi()
*
* @param object $node
* @param string $op
* @param string $a3
* @param string $a4
*/
function mm_auto_run_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
// we only run on update or insert
if ($op == 'insert' || $op == 'update') {
// get the list of configurations
if ($configurations = variable_get('mm_auto_run_configs', false)) {
// run each configuration that is enabled
$has_run = array();
foreach ($configurations as $cid => $enabled) {
if ($enabled && ! in_array($cid, $has_run)) {
$config = media_mover_api_get_configuration($cid);
$has_run[$cid] = true;
// run the media mover configuration on this node
media_mover_api_run_config($config, true, $node->nid);
}
}
}
}
}
?>
#3
#4
Hey Arthur,
I'm pretty sure this is still happening.
I've got 3 cck filefields : upload_video, transcoded_video and video_thumbnail.
I have a config called 'New Incoming Video' which converts the video to flv and saves it to the transcoded_video filefield.
Then I have a second config called 'Send to S3' which harvests from New Incoming Video's storage section and sends the converted file up to S3.
Finally a third config harvests from New Incoming Video's Storage section, creates a thumbnail then saves it to the video_thumbnail field.
I can watch this fail by adding a watchdog call into mm_auto_run_nodeapi. Can't quite see why its not working though.
I'm running 6.x-1.x-dev.