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 ebadf43..694a763 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1436,7 +1436,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 ebf6b5c..e3c29b7 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 f2bebb0..5f1ffc7 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
@@ -47,6 +47,10 @@ public function testSystemVariableUpgrade() {
'value' => 1304208002,
'variable_name' => 'cron_last',
);
+ $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 e3cb1d0..0f2ae77 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 testVariableUpgrade() {
// 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 55f20b5..e414238 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);
}
/**
@@ -1756,7 +1754,6 @@ function system_update_8008() {
*/
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',
@@ -2200,12 +2197,15 @@ function system_update_8033() {
}
/**
- * Moves cron last run time from variable to state.
+ * Moves cron last run time and cron key from variable to state.
*
* @ingroup config_upgrade
*/
function system_update_8034() {
- update_variables_to_state(array('cron_last' => 'system.cron_last'));
+ update_variables_to_state(array(
+ 'cron_last' => 'system.cron_last',
+ 'cron_key' => 'system.cron_key',
+ ));
}
/**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 107cc66..babe370 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 08e0b5c..aaacc5b 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
@@ -31,3 +31,7 @@
->key(array('name' => 'cron_last'))
->fields(array('value' => serialize(1304208002)))
->execute();
+db_merge('variable')
+ ->key(array('name' => 'cron_key'))
+ ->fields(array('value' => serialize('kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M')))
+ ->execute();