diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index f74631d..deb5de3 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1662,13 +1662,13 @@ function drupal_get_user_timezone() { * A salt based on information in settings.php, not in the database. */ function drupal_get_hash_salt() { - $drupal_hash_salt = settings()->get('drupal_hash_salt'); + $hash_salt = settings()->get('hash_salt'); // This should never happen, as it breaks user logins and many other services. // Therefore, explicitly notify the user (developer) by throwing an exception. - if (empty($drupal_hash_salt)) { - throw new \RuntimeException('Missing $settings[\'drupal_hash_salt\'] in settings.php.'); + if (empty($hash_salt)) { + throw new \RuntimeException('Missing $settings[\'hash_salt\'] in settings.php.'); } - return $drupal_hash_salt; + return $hash_salt; } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index ef9dafb..928694d 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1255,7 +1255,7 @@ function install_settings_form_submit($form, &$form_state) { 'value' => $database, 'required' => TRUE, ); - $settings['settings']['drupal_hash_salt'] = (object) array( + $settings['settings']['hash_salt'] = (object) array( 'value' => Crypt::randomStringHashed(55), 'required' => TRUE, ); diff --git a/core/includes/install.inc b/core/includes/install.inc index 895f068..4dba977 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Drupal\Component\Utility\Crypt; +use Drupal\Component\Utility\Settings; use Drupal\Core\Database\Database; use Drupal\Core\DrupalKernel; @@ -199,8 +200,14 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { } // Build list of setting names and insert the values into the global namespace. $variable_names = array(); + $settings_settings = array(); foreach ($settings as $setting => $data) { - _drupal_rewrite_settings_global($GLOBALS[$setting], $data); + if ($setting != 'settings') { + _drupal_rewrite_settings_global($GLOBALS[$setting], $data); + } + else { + _drupal_rewrite_settings_global($settings_settings, $data); + } $variable_names['$'. $setting] = $setting; } $contents = file_get_contents(DRUPAL_ROOT . '/' . $settings_file); @@ -307,6 +314,14 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { if (file_put_contents(DRUPAL_ROOT . '/' . $settings_file, $buffer) === FALSE) { throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file))); } + else { + // In case any $settings variables were written, import them into the + // Settings singleton. + if (!empty($settings_settings)) { + $old_settings = settings()->getAll(); + new Settings($settings_settings + $old_settings); + } + } } else { throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file))); diff --git a/core/rebuild.php b/core/rebuild.php index 236b97c..81d9f55 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -24,7 +24,7 @@ if (settings()->get('rebuild_access', FALSE) || (isset($_GET['token'], $_GET['timestamp']) && ((REQUEST_TIME - $_GET['timestamp']) < 300) && - ($_GET['token'] === Crypt::hmacBase64($_GET['timestamp'], settings()->get('drupal_hash_salt'))) + ($_GET['token'] === Crypt::hmacBase64($_GET['timestamp'], settings()->get('hash_salt'))) )) { drupal_rebuild(); diff --git a/core/scripts/rebuild_token_calculator.sh b/core/scripts/rebuild_token_calculator.sh index 2bc773e..a75c9b6 100755 --- a/core/scripts/rebuild_token_calculator.sh +++ b/core/scripts/rebuild_token_calculator.sh @@ -19,6 +19,6 @@ } $timestamp = time(); -$token = Crypt::hmacBase64($timestamp, settings()->get('drupal_hash_salt')); +$token = Crypt::hmacBase64($timestamp, settings()->get('hash_salt')); print "timestamp=$timestamp&token=$token\n"; diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 2be917d..ad2c404 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -244,7 +244,7 @@ */ /** - * Salt for one-time login links and cancel links, form tokens, etc. + * Salt for one-time login links, cancel links, form tokens, etc. * * This variable will be set to a random value by the installer. All one-time * login links will be invalidated if the value is changed. Note that if your @@ -257,10 +257,10 @@ * * Example: * @code - * $settings['drupal_hash_salt'] = file_get_contents('/home/example/salt.txt'); + * $settings['hash_salt'] = file_get_contents('/home/example/salt.txt'); * @endcode */ -$settings['drupal_hash_salt'] = ''; +$settings['hash_salt'] = ''; /** * Access control for update.php script.