diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index c757d1e63d4..21298b41298 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -170,7 +170,7 @@ final class Settings { */ public static function getApcuPrefix($identifier, $root, $site_path = '') { if (static::get('apcu_ensure_unique_prefix', TRUE)) { - return 'drupal.' . $identifier . '.' . hash_hmac('sha256', $identifier, static::get('hash_salt', $root . '/' . $site_path)); + return 'drupal.' . $identifier . '.' . hash_hmac('sha256', $identifier, static::get('hash_salt') . '.' . $root . '/' . $site_path); } return 'drupal.' . $identifier . '.' . Crypt::hashBase64($root . '/' . $site_path); } diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php index 59ec7d2a9b7..c92f6768a44 100644 --- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php @@ -118,4 +118,17 @@ class SettingsTest extends UnitTestCase { serialize(new Settings([])); } + /** + * Tests Settings::getApcuPrefix(). + * + * @covers ::getApcuPrefix + */ + public function testGetApcuPrefix() { + $settings = new Settings(array('hash_salt' => 123)); + $this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b')); + + $settings = new Settings(array('hash_salt' => 123, 'apcu_ensure_unique_prefix' => FALSE)); + $this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b')); + } + }