summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-07-27 12:56:34 (GMT)
committerAlex Pott2015-07-27 12:56:34 (GMT)
commit5168706ffa5c13a09e4e3a403bd8c2062dbc64ff (patch)
treec010e73203c288009b0a8848862367ad85ec5c3c
parent8ddd1342951f32d398552fbf312ac53f71d72db6 (diff)
Issue #2501183 by borisson_, dileepmaurya, Gábor Hojtsy, Berdir: LocaleLookup cache ID is using numeric indexes of the roles field, not role ID's
-rw-r--r--core/modules/locale/src/LocaleLookup.php2
-rw-r--r--core/modules/locale/tests/src/Unit/LocaleLookupTest.php4
2 files changed, 3 insertions, 3 deletions
diff --git a/core/modules/locale/src/LocaleLookup.php b/core/modules/locale/src/LocaleLookup.php
index f5b4fc1..d46ae4b 100644
--- a/core/modules/locale/src/LocaleLookup.php
+++ b/core/modules/locale/src/LocaleLookup.php
@@ -117,7 +117,7 @@ class LocaleLookup extends CacheCollector {
// for example, strings for admin menu items and settings forms are not
// cached for anonymous users.
$user = \Drupal::currentUser();
- $rids = $user ? implode(':', array_keys($user->getRoles())) : '0';
+ $rids = $user ? implode(':', $user->getRoles()) : '';
$this->cid = "locale:{$this->langcode}:{$this->context}:$rids";
// Getting the roles from the current user might have resulted in t()
diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
index fafcb45..a650840 100644
--- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
+++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
@@ -111,7 +111,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->cache->expects($this->once())
->method('get')
- ->with('locale:en:irrelevant:0', FALSE);
+ ->with('locale:en:irrelevant:anonymous', FALSE);
$this->storage->expects($this->once())
->method('findTranslation')
@@ -183,7 +183,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->cache->expects($this->once())
->method('get')
- ->with('locale:' . $langcode . ':' . $context . ':0', FALSE);
+ ->with('locale:' . $langcode . ':' . $context . ':anonymous', FALSE);
$locale_lookup = new LocaleLookup($langcode, $context, $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack);
$this->assertSame($expected, $locale_lookup->get($string));