From 90c513b8620394221feb5bfedf720fdeae527cd4 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 17 Dec 2013 21:58:12 -0800 Subject: [PATCH] Issue #2157855 by jessebeach | moshe weitzman: Poorly named cache id in toolbar. --- .../toolbar/Tests/ToolbarAdminMenuTest.php | 16 ++++++++-------- core/modules/toolbar/toolbar.module | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarAdminMenuTest.php b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarAdminMenuTest.php index 808f8afddd2..8ccec8ec790 100644 --- a/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarAdminMenuTest.php @@ -238,12 +238,12 @@ class ToolbarAdminMenuTest extends WebTestBase { // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user against the language "en". - $cache = $toolbarCache->get($admin_user_id . ':' . 'en'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'en'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user against the language "en".'); // Assert that no toolbar cache exists for admin_user against the // language "fr". - $cache = $toolbarCache->get($admin_user_id . ':' . 'fr'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'fr'); $this->assertFalse($cache, 'No toolbar cache exists for admin_user against the language "fr".'); // Install a second language. @@ -258,7 +258,7 @@ class ToolbarAdminMenuTest extends WebTestBase { // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user against the language "fr". - $cache = $toolbarCache->get($admin_user_id . ':' . 'fr'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . 'fr'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user against the language "fr".'); // Log in the admin_user_2 user. We will use this user as a control to @@ -271,7 +271,7 @@ class ToolbarAdminMenuTest extends WebTestBase { $this->assertResponse(200); // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user_2 against the language "en". - $cache = $toolbarCache->get($admin_user_2_id . ':' . 'en'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'en'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "en".'); // Request a page in 'fr' to create the cache. @@ -279,7 +279,7 @@ class ToolbarAdminMenuTest extends WebTestBase { $this->assertResponse(200); // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user against the language "fr". - $cache = $toolbarCache->get($admin_user_2_id . ':' . 'fr'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'fr'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "fr".'); // Log in admin_user and clear the caches for this user using a tag. @@ -301,12 +301,12 @@ class ToolbarAdminMenuTest extends WebTestBase { // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user_2 against the language "en". - $cache = $toolbarCache->get($admin_user_2_id . ':' . 'en'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'en'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "en".'); // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user_2 against the language "fr". - $cache = $toolbarCache->get($admin_user_2_id . ':' . 'fr'); + $cache = $toolbarCache->get('toolbar_' . $admin_user_2_id . ':' . 'fr'); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_2_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user_2 against the language "fr".'); } @@ -390,7 +390,7 @@ class ToolbarAdminMenuTest extends WebTestBase { // Assert that a cache tag in the toolbar cache under the key "user" exists // for admin_user against the language "xx". - $cache = $toolbarCache->get($admin_user_id . ':' . $langcode); + $cache = $toolbarCache->get('toolbar_' . $admin_user_id . ':' . $langcode); $this->assertEqual($cache->tags[0], 'user:' . $admin_user_id, 'A cache tag in the toolbar cache under the key "user" exists for admin_user against the language "xx".'); // Get a baseline hash for the admin menu subtrees before translating one diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index b8b0dcb70ee..c8612df2a6c 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -690,7 +690,7 @@ function toolbar_user_role_update(RoleInterface $role) { * A unique cache ID for the user. */ function _toolbar_get_user_cid($uid) { - return $uid . ':' . \Drupal::languageManager()->getLanguage(Language::TYPE_INTERFACE)->id; + return 'toolbar_' . $uid . ':' . \Drupal::languageManager()->getLanguage(Language::TYPE_INTERFACE)->id; } /**