Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1116 diff -u -p -r1.1116 common.inc --- includes/common.inc 25 Feb 2010 20:57:39 -0000 1.1116 +++ includes/common.inc 26 Feb 2010 23:02:01 -0000 @@ -4373,6 +4373,14 @@ function drupal_cron_run() { // Allow execution to continue even if the request gets canceled. @ignore_user_abort(TRUE); + // Prevent session information from being saved while the cron is running. + drupal_save_session(FALSE); + + // Force the current user to anonymous to ensure consistent permissions on + // cron runs. + $original_user = $GLOBALS['user']; + $GLOBALS['user'] = drupal_anonymous_user(); + // Try to allocate enough time to run all the hook_cron implementations. drupal_set_time_limit(240); @@ -4433,6 +4441,9 @@ function drupal_cron_run() { $queue->deleteItem($item); } } + // Restore the user. + $GLOBALS['user'] = $original_user; + return $return; } @@ -4447,6 +4458,10 @@ function drupal_cron_cleanup() { // Release cron semaphore variable_del('cron_semaphore'); } + + drupal_save_session(TRUE); + + return TRUE; } /** Index: modules/dblog/dblog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v retrieving revision 1.34 diff -u -p -r1.34 dblog.test --- modules/dblog/dblog.test 26 Feb 2010 17:22:39 -0000 1.34 +++ modules/dblog/dblog.test 26 Feb 2010 23:02:04 -0000 @@ -74,9 +74,7 @@ class DBLogTestCase extends DrupalWebTes $this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); // Run cron job. - $this->drupalGet('admin/reports/status/run-cron'); - $this->assertResponse(200); - $this->assertText(t('Cron ran successfully'), t('Cron ran successfully')); + $this->cronRun(); // Verify dblog row count equals row limit plus one because cron adds a record after it runs. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); $this->assertTrue($count == $row_limit + 1, t('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit)));