Issue #2530936 by webflo: Ensure that the classloader prefix is really unique

8.0.x
Alex Pott 2015-07-14 11:04:37 +01:00
parent 24219febf3
commit 1bb4e43db8
2 changed files with 14 additions and 1 deletions

View File

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

View File

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