Issue #1798734 by Berdir, ACF, leschekfm, heyrocker, alexpott: Convert drupal_private_key() to the configuration system.

8.0.x
Dries 2013-02-27 16:27:35 -05:00
parent 1af585da63
commit 6aa308f8ea
4 changed files with 16 additions and 2 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -59,6 +59,10 @@ class StateSystemUpgradePathTest extends UpgradePathTestBase {
'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',

View File

@ -47,6 +47,10 @@ db_merge('variable')
->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)))