diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
index 0966937..47617a0 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
@@ -22,7 +22,7 @@ public static function getInfo() {
public function testCron() {
// Create feed and test basic updating on cron.
global $base_url;
- $key = config('system.cron')->get('key');
+ $key = state()->get('system.cron_key');
$this->createSampleNodes();
$feed = $this->createFeed();
$this->cronRun();
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index f9bc3f4..f6bfd5a 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1430,7 +1430,7 @@ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path
* Runs cron in the Drupal installed by Simpletest.
*/
protected function cronRun() {
- $this->drupalGet('cron/' . config('system.cron')->get('key'));
+ $this->drupalGet('cron/' . state()->get('system.cron_key'));
}
/**
diff --git a/core/modules/system/config/system.cron.yml b/core/modules/system/config/system.cron.yml
index b9a5096..aa41f1b 100644
--- a/core/modules/system/config/system.cron.yml
+++ b/core/modules/system/config/system.cron.yml
@@ -1,4 +1,3 @@
-key: ''
threshold:
autorun: '10800'
requirements_warning: '172800'
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
index 1bdb269..8aa996f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
@@ -42,7 +42,7 @@ function testCronRun() {
$this->assertResponse(403);
// Run cron anonymously with the valid cron key.
- $key = config('system.cron')->get('key');
+ $key = state()->get('system.cron_key');
$this->drupalGet('cron/' . $key);
$this->assertResponse(204);
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
index 5537083..4fb86d0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
@@ -35,6 +35,10 @@ public function testSystemVariableUpgrade() {
$expected_state = array();
+ $expected_state['system.cron_key'] = array(
+ 'value' => 'kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M',
+ 'variable_name' => 'cron_key',
+ );
$expected_state['update.last_check'] = array(
'value' => 1304208000,
'variable_name' => 'update_last_check',
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
index db95f06..88c24b3 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
@@ -35,7 +35,6 @@ public function testSystemVariableUpgrade() {
// Verify that variables were properly upgraded.
$expected_config['system.cron'] = array(
- 'key' => 'kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M',
'threshold.autorun' => '86400',
'threshold.requirements_warning' => '86400',
'threshold.requirements_error' => '172800',
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 4bced68..998ee4f 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -294,7 +294,7 @@ 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('cron/' . $cron_config->get('key'))));
+ $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . state()->get('system.cron_key'))));
$requirements['cron'] = array(
'title' => $t('Cron maintenance tasks'),
@@ -512,11 +512,9 @@ function system_install() {
variable_set('theme_default', 'stark');
config_install_default_config('theme', 'stark');
- // Populate the cron key variable.
+ // Populate the cron key state variable.
$cron_key = drupal_hash_base64(drupal_random_bytes(55));
- config('system.cron')
- ->set('key', $cron_key)
- ->save();
+ state()->set('system.cron_key', $cron_key);
}
/**
@@ -1750,13 +1748,12 @@ function system_update_8008() {
}
/**
- * Moves cron system settings from variable to config.
+ * Moves cron system settings from variable to config/state.
*
* @ingroup config_upgrade
*/
function system_update_8009() {
update_variables_to_config('system.cron', array(
- 'cron_key' => 'key',
'cron_safe_threshold' => 'threshold.autorun',
'cron_threshold_warning' => 'threshold.requirements_warning',
'cron_threshold_error' => 'threshold.requirements_error',
@@ -2202,6 +2199,15 @@ function system_update_8032() {
}
/**
+ * Moves cron_key from variable to state.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8033() {
+ update_variables_to_state(array('cron_key' => 'system.cron_key'));
+}
+
+/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 7f9f33a..dc99d03 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -1101,7 +1101,7 @@ function system_cron_page() {
* @see system_cron_page().
*/
function system_cron_access($key) {
- if ($key != config('system.cron')->get('key')) {
+ if ($key != state()->get('system.cron_key')) {
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
return FALSE;
}
diff --git a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
index 8f19d1b..5301eb6 100644
--- a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
+++ b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
@@ -19,3 +19,7 @@
->key(array('name' => 'update_last_email_notification'))
->fields(array('value' => serialize(1304208000)))
->execute();
+db_merge('variable')
+ ->key(array('name' => 'cron_key'))
+ ->fields(array('value' => serialize('kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M')))
+ ->execute();