function cron_debug_run in Cron Debug 7
Run a single cron function. Will call the cron hook for a module, log the progress and go to the Cron Debug form.
Parameters
string $module: name of the module
1 string reference to 'cron_debug_run'
- cron_debug_menu in ./
cron_debug.module - Implements hook_menu().
File
- ./
cron_debug.module, line 288 - Cron debugging for administrators.
Code
function cron_debug_run($module) {
$function = $module . '_cron';
// Verify that the module exists.
if (!module_exists($module)) {
drupal_set_message(t('Module %module is not enabled.', array(
'%module' => $module,
)));
}
elseif (!function_exists($function)) {
drupal_set_message(t('Module %module does not implement cron.', array(
'%module' => $module,
)));
}
else {
// Change the flag to the current module name
variable_set('cron_debug_flag', $module);
// Register start of this module. Enables us to see errors for the hook in the log
watchdog('cron debug', 'Starting cron for @module module.', array(
'@module' => $module,
));
// Start timer and run function
timer_start($function);
$function();
// Stop the timer, get the time for this module in seconds
$timer = timer_stop($function);
$total = round($timer['time'] / 1000, 3);
drupal_set_message(t('%function successfully completed in @secs seconds.', array(
'%function' => $function . '()',
'@secs' => $total,
)));
// Get rid of the flag
variable_del('cron_debug_flag');
// Register end of this module. Errors after this are not related
watchdog('cron debug', 'Ended cron for @module module.', array(
'@module' => $module,
));
}
drupal_goto('admin/config/system/cron/debug');
}