? drupal_cron-19173-40-axyjo.patch
? drupal_cron-19173-43-axyjo.patch
? sites/default/files
? sites/default/settings.php
Index: cron.php
===================================================================
RCS file: /cvs/drupal/drupal/cron.php,v
retrieving revision 1.42
diff -u -p -r1.42 cron.php
--- cron.php	8 Feb 2009 20:27:51 -0000	1.42
+++ cron.php	30 Jun 2009 19:03:52 -0000
@@ -4,6 +4,8 @@
 /**
  * @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.
  */
 
 /**
@@ -13,8 +15,29 @@ define('DRUPAL_ROOT', getcwd());
 
 include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+var_dump($argv);
 if (isset($_GET['cron_key']) && variable_get('cron_key', 'drupal') == $_GET['cron_key']) {
-  drupal_cron_run();
+  if (isset($_GET['include'])) $include = $_GET['include'];
+  if (isset($_GET['exclude'])) $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 could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.925
diff -u -p -r1.925 common.inc
--- includes/common.inc	18 Jun 2009 21:19:01 -0000	1.925
+++ includes/common.inc	30 Jun 2009 19:03:58 -0000
@@ -3360,7 +3360,7 @@ function drupal_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);
 
@@ -3392,13 +3392,59 @@ function drupal_cron_run() {
 
     // Lock cron semaphore
     variable_set('cron_semaphore', REQUEST_TIME);
+    
+    // Create $cron_message so that it is defined.
+    $cron_message = '';
 
     // 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', REQUEST_TIME);
-    watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
 
     // Release cron semaphore
     variable_del('cron_semaphore');
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.53
diff -u -p -r1.53 system.test
--- modules/system/system.test	28 Jun 2009 03:56:43 -0000	1.53
+++ modules/system/system.test	30 Jun 2009 19:04:02 -0000
@@ -318,6 +318,14 @@ class CronRunTestCase extends DrupalWebT
     $key = variable_get('cron_key', 'drupal');
     $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => 'cron_key=' . $key));
     $this->assertResponse(200);
+    
+    // Run cron with an include parameter.
+    $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key, 'include' => 'system')));
+    $this->assertResponse(200);
+    
+    // Run cron with an exclude parameter.
+    $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key, 'exclude' => 'system')));
+    $this->assertResponse(200);
 
     // Execute cron directly.
     $this->assertTrue(drupal_cron_run(), t('Cron ran successfully.'));
