Commit 6aa308f8 authored by Dries's avatar Dries

Issue #1798734 by Berdir, ACF, leschekfm, heyrocker, alexpott: Convert...

Issue #1798734 by Berdir, ACF, leschekfm, heyrocker, alexpott: Convert drupal_private_key() to the configuration system.
parent 1af585da
......@@ -4814,9 +4814,9 @@ function drupal_get_hash_salt() {
* The private key.
*/
function drupal_get_private_key() {
if (!($key = variable_get('drupal_private_key', 0))) {
if (!($key = state()->get('system.private_key'))) {
$key = drupal_hash_base64(drupal_random_bytes(55));
variable_set('drupal_private_key', $key);
state()->set('system.private_key', $key);
}
return $key;
}
......
......@@ -400,6 +400,12 @@ function update_prepare_d8_bootstrap() {
$theme_config->save();
$disabled_themes->save();
// Migrate the private key to state. This is used to create the token for
// the upgrade batch so needs to be be done before the upgrade has begun.
update_variables_to_state(array(
'drupal_private_key' => 'system.private_key',
));
// Update the dynamic include paths that might be used before running the
// proper update functions.
update_prepare_stored_includes();
......
......@@ -59,6 +59,10 @@ public function testSystemVariableUpgrade() {
'value' => 'kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M',
'variable_name' => 'cron_key',
);
$expected_state['system.private_key'] = array(
'value' => 'G38mKqASKus8VGMkMzVuXImYbzspCQ1iRT2iEZpMYmQ',
'variable_name' => 'drupal_private_key',
);
$expected_state['tracker.index_nid'] = array(
'value' => 0,
'variable_name' => 'tracker_index_nid',
......
......@@ -47,6 +47,10 @@
->key(array('name' => 'cron_key'))
->fields(array('value' => serialize('kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M')))
->execute();
db_merge('variable')
->key(array('name' => 'drupal_private_key'))
->fields(array('value' => serialize('G38mKqASKus8VGMkMzVuXImYbzspCQ1iRT2iEZpMYmQ')))
->execute();
db_merge('variable')
->key(array('name' => 'node_cron_comments_scale'))
->fields(array('value' => serialize(1.0 / 1000)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment