diff --git i/core/cron.php w/core/cron.php index fa9aa14..301047a 100644 --- i/core/cron.php +++ w/core/cron.php @@ -16,7 +16,7 @@ define('DRUPAL_ROOT', getcwd()); include_once DRUPAL_ROOT . '/core/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); -if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) { +if (!isset($_GET['cron_key']) || config('system.cron')->get('cron_key') != $_GET['cron_key']) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); drupal_access_denied(); } diff --git i/core/modules/aggregator/aggregator.test w/core/modules/aggregator/aggregator.test index 2149bed..e0dfd90 100644 --- i/core/modules/aggregator/aggregator.test +++ w/core/modules/aggregator/aggregator.test @@ -798,7 +798,7 @@ class AggregatorCronTestCase extends AggregatorTestCase { public function testCron() { // Create feed and test basic updating on cron. global $base_url; - $key = variable_get('cron_key', 'drupal'); + $key = config('system.cron')->get('cron_key'); $this->createSampleNodes(); $feed = $this->createFeed(); $this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key))); diff --git i/core/modules/simpletest/drupal_web_test_case.php w/core/modules/simpletest/drupal_web_test_case.php index ded4ad0..f350499 100644 --- i/core/modules/simpletest/drupal_web_test_case.php +++ w/core/modules/simpletest/drupal_web_test_case.php @@ -2184,7 +2184,7 @@ class DrupalWebTestCase extends DrupalTestCase { * Runs cron in the Drupal installed by Simpletest. */ protected function cronRun() { - $this->drupalGet($GLOBALS['base_url'] . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal')))); + $this->drupalGet($GLOBALS['base_url'] . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => config('system.cron')->get('cron_key')))); } /** diff --git i/core/modules/system/system.admin.inc w/core/modules/system/system.admin.inc index 978b0f4..8ea3f56 100644 --- i/core/modules/system/system.admin.inc +++ w/core/modules/system/system.admin.inc @@ -1588,7 +1588,7 @@ function system_cron_settings() { $form['cron']['cron_safe_threshold'] = array( '#type' => 'select', '#title' => t('Run cron every'), - '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD), + '#default_value' => config('system.cron')->get('cron_safe_threshold'), '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'), ); diff --git i/core/modules/system/system.install w/core/modules/system/system.install index 14d4853..0ba5d74 100644 --- i/core/modules/system/system.install +++ w/core/modules/system/system.install @@ -254,9 +254,9 @@ function system_requirements($phase) { // Report cron status. if ($phase == 'runtime') { // Cron warning threshold defaults to two days. - $threshold_warning = variable_get('cron_threshold_warning', 172800); + $threshold_warning = config('system.cron')->get('cron_threshold_warning'); // Cron error threshold defaults to two weeks. - $threshold_error = variable_get('cron_threshold_error', 1209600); + $threshold_error = config('system.cron')->get('cron_threshold_error'); // Cron configuration help text. $help = $t('For more information, see the online handbook entry for configuring cron jobs.', array('@cron-handbook' => 'http://drupal.org/cron')); @@ -283,7 +283,8 @@ function system_requirements($phase) { } $description .= ' ' . $t('You can run cron manually.', array('@cron' => url('admin/reports/status/run-cron'))); - $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => variable_get('cron_key', 'drupal')))))); + $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => config('system.cron')->get('cron_key')))))); + $requirements['cron'] = array( 'title' => $t('Cron maintenance tasks'), @@ -515,7 +516,7 @@ function system_install() { // Populate the cron key variable. $cron_key = drupal_hash_base64(drupal_random_bytes(55)); - variable_set('cron_key', $cron_key); + config('system.cron')->set('cron_key', $cron_key); } /** @@ -1761,6 +1762,25 @@ function system_update_8004() { } /** + * Moves system settings from variable to config. + * + * @see http://drupal.org/node/1493098 + */ +function system_update_8005() { + $var_names = array_keys(config('system.cron')->get()); + $query = db_select('variable', 'v') + ->fields('v') + ->condition('name', $var_names, 'IN'); + $del = db_delete('variable')->condition('name', $var_names, 'IN'); + $var_values = $query->execute()->fetchAllKeyed(0); + $del->execute(); + $config = config('system.cron'); + foreach($var_values as $name => $val) { + $config->set($name, $val); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x" * The next series of updates should start at 9000. */ diff --git i/core/modules/system/system.module w/core/modules/system/system.module index 94fd3e0..24ec64e 100644 --- i/core/modules/system/system.module +++ w/core/modules/system/system.module @@ -11,11 +11,6 @@ const DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600; /** - * Default interval for automatic cron executions in seconds. - */ -const DRUPAL_CRON_DEFAULT_THRESHOLD = 10800; - -/** * New users will be set to the default time zone at registration. */ const DRUPAL_USER_TIMEZONE_DEFAULT = 0; @@ -3515,7 +3510,7 @@ function system_run_automated_cron() { // If the site is not fully installed, suppress the automated cron run. // Otherwise it could be triggered prematurely by Ajax requests during // installation. - if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') { + if (($threshold = config('system.cron')->get('cron_safe_threshold')) > 0 && variable_get('install_task') == 'done') { $cron_last = variable_get('cron_last', NULL); if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { drupal_cron_run(); diff --git i/core/modules/system/system.test w/core/modules/system/system.test index 9287d16..42fc32e 100644 --- i/core/modules/system/system.test +++ w/core/modules/system/system.test @@ -754,7 +754,7 @@ class CronRunTestCase extends DrupalWebTestCase { $this->assertResponse(403); // Run cron anonymously with the valid cron key. - $key = variable_get('cron_key', 'drupal'); + $key = config('system.cron')->get('cron_key'); $this->drupalGet($base_url . '/core/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key))); $this->assertResponse(200); } @@ -771,7 +771,7 @@ class CronRunTestCase extends DrupalWebTestCase { $cron_last = time(); $cron_safe_threshold = 100; variable_set('cron_last', $cron_last); - variable_set('cron_safe_threshold', $cron_safe_threshold); + config('system.cron')->set('cron_safe_threshold', $cron_safe_threshold); $this->drupalGet(''); $this->assertTrue($cron_last == variable_get('cron_last', NULL), t('Cron does not run when the cron threshold is not passed.'));