diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index 8603f67..2003e4e 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -74,7 +74,8 @@ public function __construct($langcode, $context, StringStorageInterface $string_ // Add the current user's role IDs to the cache key, this ensures that, for // example, strings for admin menu items and settings forms are not cached // for anonymous users. - $rids = isset($GLOBALS['user']) ? implode(':', array_keys($GLOBALS['user']->getRoles())) : '0'; + $user = \Drupal::currentUser(); + $rids = $user ? implode(':', array_keys($user->getRoles())) : '0'; parent::__construct("locale:$langcode:$context:$rids", $cache, $lock, array('locale' => TRUE)); } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index 875741b..cd8ec73 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -62,13 +62,6 @@ function testUninstallProcess() { $language_manager->reset(); $language_manager->init(); // Check the UI language. - - // @todo: If the global user is an Entity, getting the roles - // from it within LocaleLookup results in a loop that invokes LocaleLookup - // again. - global $user; - $user = drupal_anonymous_user(); - $this->assertEqual(language(Language::TYPE_INTERFACE)->id, $this->langcode, String::format('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->id))); // Enable multilingual workflow option for articles.