diff -upr drupal-7.x-dev-orig/cron.php drupal7/cron.php --- drupal-7.x-dev-orig/cron.php 2008-05-26 17:24:42.000000000 +0000 +++ drupal7/cron.php 2008-08-14 10:11:12.000000000 +0000 @@ -4,12 +4,34 @@ /** * @file * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs). + * Takes one parameter, include or exclude, which contains a comma separated + * list of modules to either include or exclude from the cron run. */ include_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); if (isset($_GET['cron_key']) && variable_get('cron_key', 'drupal') == $_GET['cron_key']) { - drupal_cron_run(); + $include = $_GET['include']; + $exclude = $_GET['exclude']; + + if (isset($include) && isset($exclude)) { + watchdog('cron', t('Cron has been issued both the include and the exclude parameters.'), array(), WATCHDOG_ERROR); + return false; + } + elseif (isset($include) && !isset($exclude)) { + $cron_param = $include; + $mode = 'include'; + } + elseif (!isset($include) && isset($exclude)) { + $cron_param = $exclude; + $mode = 'exclude'; + } + else { + $cron_param = ''; + $mode = ''; + } + + drupal_cron_run($cron_param, $mode); } else { watchdog('cron', 'Cron did not run because an invalid key used.', array(), WATCHDOG_NOTICE); diff -upr drupal-7.x-dev-orig/includes/common.inc drupal7/includes/common.inc --- drupal-7.x-dev-orig/includes/common.inc 2008-08-13 07:10:20.000000000 +0000 +++ drupal7/includes/common.inc 2008-08-14 13:15:20.000000000 +0000 @@ -2534,7 +2534,7 @@ function page_set_cache() { * @return * Returns TRUE if ran successfully */ -function drupal_cron_run() { +function drupal_cron_run($list, $mode, $delimiter = ',') { // Allow execution to continue even if the request gets canceled. @ignore_user_abort(TRUE); @@ -2566,11 +2566,54 @@ function drupal_cron_run() { variable_set('cron_semaphore', time()); // Iterate through the modules calling their cron handlers (if any): - module_invoke_all('cron'); + if ($list == '' && $mode == '') { + //No parameters were passed, so we're running all modules + module_invoke_all('cron'); + watchdog('cron', t('Cron run completed for all modules.'), array(), WATCHDOG_NOTICE); + } + elseif($list != '' && $mode == 'include') { + $module_list = module_list(); + $cron_modules = explode($delimiter, $list); + //Get only a list of modules that are specified AND enabled + $run_array = array_intersect($module_list, $cron_modules); + foreach($run_array as $run_module) { + module_invoke($run_module, 'cron'); + $cron_message .= t($run_module).', '; + } + //Remove the extra ', ' from the end of the string + $cron_message = substr($cron_message, 0, -2); + if ($cron_message != '') { + watchdog('cron', t('Cron run completed for modules: @cron_message.', array('@cron_message' => $cron_message)), array(), WATCHDOG_NOTICE); + } + else { + watchdog('cron', t('Cron did not run because no valid modules were specified.'), array(), WATCHDOG_ERROR); + } + } + elseif($list != '' && $mode == 'exclude') { + $module_list = module_list(); + $cron_modules = explode($delimiter, $list); + //Get only a list of modules that are NOT specified but enabled + $run_array = array_diff($module_list, $cron_modules); + foreach($run_array as $run_module) { + module_invoke($run_module, 'cron'); + $cron_message .= t($run_module).', '; + } + //Remove the extra ', ' from the end of the string + $cron_message = substr($cron_message, 0, -2); + if ($cron_message != '') { + watchdog('cron', t('Cron run completed for modules: @cron_message.', array('@cron_message' => $cron_message)), array(), WATCHDOG_NOTICE); + } + else { + watchdog('cron', t('Cron did not run because no valid modules were specified.'), array(), WATCHDOG_ERROR); + } + } + else { + //catch anything that's not covered already. + return false; + } // Record cron time variable_set('cron_last', time()); - watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE); // Release cron semaphore variable_del('cron_semaphore');