diff --git a/core/modules/locale/src/LocaleLookup.php b/core/modules/locale/src/LocaleLookup.php index f5b4fc1643d97b6fcf796306fad23a349416dda1..d46ae4b2bad588ad28c494340e2d365d0559f81a 100644 --- a/core/modules/locale/src/LocaleLookup.php +++ b/core/modules/locale/src/LocaleLookup.php @@ -117,7 +117,7 @@ protected function getCid() { // 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 fafcb458cf1a3d478921f4487c08caf62c19b62d..a650840192f77271279dd599980277802998a38d 100644 --- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php +++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php @@ -111,7 +111,7 @@ public function testResolveCacheMissWithoutFallback() { $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 @@ public function testResolveCacheMissWithFallback($langcode, $string, $context, $ $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));