Issue #2501183 by borisson_, dileepmaurya, Gábor Hojtsy, Berdir: LocaleLookup cache ID is using numeric indexes of the roles field, not role ID's

8.0.x
Alex Pott 2015-07-27 13:56:34 +01:00
parent 8ddd134295
commit 5168706ffa
2 changed files with 3 additions and 3 deletions

View File

@ -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()

View File

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