diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php index d3630c4..5350207 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php @@ -83,7 +83,6 @@ public function applies(Request $request) { * {@inheritdoc} */ public function authenticate(Request $request) { - global $user; $account = NULL; @@ -112,11 +111,6 @@ public function authenticate(Request $request) { // for later access. $request->attributes->set('_authentication_provider', $this->triggeredProviderId); - // The global $user object is included for backward compatibility only and - // should be considered deprecated. - // @todo Remove this line once global $user is no longer used. - $user = $account; - return $account; } diff --git a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php index ae108dc..dee78ff 100644 --- a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php +++ b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php @@ -30,12 +30,10 @@ public function applies(Request $request) { * {@inheritdoc} */ public function authenticate(Request $request) { - // Global $user is deprecated, but the session system is still based on it. - global $user; require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); drupal_session_initialize(); if (drupal_session_started()) { - return $user; + return \Drupal::currentUser(); } return NULL; } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index c747cca..8fb1271 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -277,7 +277,7 @@ protected function checkCreateAccess(AccountInterface $account, array $context, */ protected function prepareUser(AccountInterface $account = NULL) { if (!$account) { - $account = $GLOBALS['user']; + $account = \Drupal::currentUser(); } return $account; } diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php index 5bdf61c..a2aa7d8 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php @@ -78,13 +78,13 @@ public function onException(GetResponseForExceptionEvent $event) { * {@inheritdoc} * * The priority for request must be higher than the highest event subscriber - * accessing the global $user. + * accessing the current user. * The priority for the response must be as low as possible allowing e.g the * Cookie provider to send all relevant session data to the user. */ public static function getSubscribedEvents() { // Priority must be higher than LanguageRequestSubscriber as LanguageManager - // access global $user in case language module enabled. + // access current user in case language module enabled. $events[KernelEvents::REQUEST][] = array('onKernelRequestAuthenticate', 300); $events[KernelEvents::RESPONSE][] = array('onRespond', 0); $events[KernelEvents::EXCEPTION][] = array('onException', 0); diff --git a/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php index 6e577b9..58cb0be 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/AuthenticationEnhancer.php @@ -55,11 +55,6 @@ public function enhance(array $defaults, Request $request) { $anonymous_user = drupal_anonymous_user(); $this->container->set('current_user', $anonymous_user, 'request'); - - // The global $user object is included for backward compatibility only - // and should be considered deprecated. - // @todo Remove this line once global $user is no longer used. - $GLOBALS['user'] = $anonymous_user; } } return $defaults;