From 4e85bfc9b366df5eaa6276a7fc02cc8b1fc05322 Mon Sep 17 00:00:00 2001 From: Brad Erickson Date: Mon, 26 Nov 2012 20:13:25 -0800 Subject: [PATCH] Add cron_run global set to TRUE during cron runs --- core/includes/bootstrap.inc | 5 ++++- core/includes/common.inc | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 43d1eac..60772ea 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -722,7 +722,7 @@ function unicode_check() { * Sets the base URL, cookie domain, and session name from configuration. */ function drupal_settings_initialize() { - global $base_url, $base_path, $base_root, $script_path; + global $base_url, $base_path, $base_root, $script_path, $cron_run; // Export these settings.php variables to the global namespace. global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url, $config_directories; @@ -837,6 +837,9 @@ function drupal_settings_initialize() { } $prefix = ini_get('session.cookie_secure') ? 'SSESS' : 'SESS'; session_name($prefix . substr(hash('sha256', $session_name), 0, 32)); + + // Always FALSE unless set to true in drupal_cron_run() + $cron_run = FALSE; } /** diff --git a/core/includes/common.inc b/core/includes/common.inc index edd7c2d..c33ba9e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4930,6 +4930,9 @@ function drupal_cron_run() { // Allow execution to continue even if the request gets canceled. @ignore_user_abort(TRUE); + // Enable cron_run for functions to detect cron run. + $GLOBALS['cron_run'] = TRUE; + // Prevent session information from being saved while cron is running. $original_session_saving = drupal_save_session(); drupal_save_session(FALSE); @@ -5000,6 +5003,9 @@ function drupal_cron_run() { $GLOBALS['user'] = $original_user; drupal_save_session($original_session_saving); + // Reset cron_run on completion. + $GLOBALS['cron_run'] = FALSE; + return $return; } -- 1.7.12.3