diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 1568f45..01ce5dc 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1510,7 +1510,8 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
  * @see hook_watchdog()
  */
 function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG_NOTICE, $link = NULL) {
-  global $user, $base_root;
+  global $base_root;
+  $user = \Drupal::currentUser();
 
   static $in_error_state = FALSE;
 
@@ -1872,7 +1873,7 @@ function drupal_handle_request($test_only = FALSE) {
  * Returns the time zone of the current user.
  */
 function drupal_get_user_timezone() {
-  global $user;
+  $user = \Drupal::currentUser();
   $config = \Drupal::config('system.date');
 
   if ($user && $config->get('timezone.user.configurable') && $user->isAuthenticated() && $user->getTimezone()) {
@@ -2001,8 +2002,6 @@ function _drupal_bootstrap_kernel() {
  * Attempts to serve a page from the cache.
  */
 function _drupal_bootstrap_page_cache() {
-  global $user;
-
   require_once __DIR__ . '/cache.inc';
   require_once __DIR__ . '/database.inc';
   // Check for a cache mode force from settings.php.
@@ -2020,7 +2019,7 @@ function _drupal_bootstrap_page_cache() {
   // to serve a cached page.
   if (!$request->cookies->has(session_name()) && $cache_enabled) {
     // Make sure there is a user object because its timestamp will be checked.
-    $user = drupal_anonymous_user();
+    \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
     // Get the page from the cache.
     $cache = drupal_page_get_cache($request);
     // If there is a cached page, display it.
diff --git a/core/includes/common.inc b/core/includes/common.inc
index aff7665..50ea821 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3187,8 +3187,8 @@ function drupal_cron_run() {
 
   // Force the current user to anonymous to ensure consistent permissions on
   // cron runs.
-  $original_user = $GLOBALS['user'];
-  $GLOBALS['user'] = drupal_anonymous_user();
+  $original_user = \Drupal::currentUser();
+  \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
 
   // Try to allocate enough time to run all the hook_cron implementations.
   drupal_set_time_limit(240);
@@ -3246,7 +3246,7 @@ function drupal_cron_run() {
     }
   }
   // Restore the user.
-  $GLOBALS['user'] = $original_user;
+  \Drupal::getContainer()->set('current_user', $original_user);
   drupal_save_session($original_session_saving);
 
   return $return;
@@ -4518,7 +4518,7 @@ function drupal_render_cache_by_query($query, $function, $expire = CacheBackendI
  *   $granularity was passed in, more parts are added.
  */
 function drupal_render_cid_parts($granularity = NULL) {
-  global $theme, $base_root, $user;
+  global $theme, $base_root;
 
   $cid_parts[] = $theme;
   // If Locale is enabled but we have only one language we do not need it as cid
@@ -4534,10 +4534,10 @@ function drupal_render_cid_parts($granularity = NULL) {
     // resource drag for sites with many users, so when a module is being
     // equivocal, we favor the less expensive 'PER_ROLE' pattern.
     if ($granularity & DRUPAL_CACHE_PER_ROLE) {
-      $cid_parts[] = 'r.' . implode(',', $user->getRoles());
+      $cid_parts[] = 'r.' . implode(',', \Drupal::currentUser()->getRoles());
     }
     elseif ($granularity & DRUPAL_CACHE_PER_USER) {
-      $cid_parts[] = 'u.' . $user->id();
+      $cid_parts[] = 'u.' . \Drupal::currentUser()->id();
     }
 
     if ($granularity & DRUPAL_CACHE_PER_PAGE) {
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 1dbfec6..9ba055b 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -2739,7 +2739,7 @@ function install_configure_form_submit($form, &$form_state) {
   $account->pass = $form_state['values']['account']['pass'];
   $account->name = $form_state['values']['account']['name'];
   $account->save();
-  // Load global $user and perform final login tasks.
+  // Load current user and perform final login tasks.
   $account = user_load(1);
   user_login_finalize($account);
 
diff --git a/core/includes/language.inc b/core/includes/language.inc
index 618e3a7..aa7af69 100644
--- a/core/includes/language.inc
+++ b/core/includes/language.inc
@@ -459,8 +459,6 @@ function language_negotiation_method_invoke($method_id, $method = NULL, $request
   $results = &drupal_static(__FUNCTION__);
 
   if (!isset($results[$method_id])) {
-    global $user;
-
     $languages = language_list();
 
     if (!isset($method)) {
@@ -482,7 +480,7 @@ function language_negotiation_method_invoke($method_id, $method = NULL, $request
     }
     // If the language negotiation method has no cache preference or this is
     // satisfied we can execute the callback.
-    $cache = !isset($method['cache']) || $user->isAuthenticated() || $method['cache'] == $cache_enabled;
+    $cache = !isset($method['cache']) || \Drupal::currentUser()->isAuthenticated() || $method['cache'] == $cache_enabled;
     $callback = isset($method['callbacks']['negotiation']) ? $method['callbacks']['negotiation'] : FALSE;
     $langcode = $cache && function_exists($callback) ? $callback($languages, $request) : FALSE;
     $results[$method_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
diff --git a/core/includes/session.inc b/core/includes/session.inc
index 5ffbb8d..f154287 100644
--- a/core/includes/session.inc
+++ b/core/includes/session.inc
@@ -72,8 +72,6 @@ function _drupal_session_close() {
  *   The user's session, or an empty string if no session exists.
  */
 function _drupal_session_read($sid) {
-  global $user;
-
   // Write and Close handlers are called after destructing objects
   // since PHP 5.0.5.
   // Thus destructors can use sessions but session handler can't use objects.
@@ -86,6 +84,7 @@ function _drupal_session_read($sid) {
   $cookies = \Drupal::request()->cookies;
   if (!$cookies->has(session_name()) && !$cookies->has($insecure_session_name)) {
     $user = new UserSession();
+    \Drupal::getContainer()->set('current_user', $user);
     return '';
   }
 
@@ -134,7 +133,7 @@ function _drupal_session_read($sid) {
     'sid' => $sid,
     'value' => $user->session,
   );
-
+  \Drupal::getContainer()->set('current_user', $user);
   return $user->session;
 }
 
@@ -157,8 +156,6 @@ function _drupal_session_read($sid) {
  *   Always returns TRUE.
  */
 function _drupal_session_write($sid, $value) {
-  global $user;
-
   // The exception handler is not active at this point, so we need to do it
   // manually.
   try {
@@ -167,6 +164,8 @@ function _drupal_session_write($sid, $value) {
       return;
     }
 
+    $user = \Drupal::currentUser();
+
     // Check whether $_SESSION has been changed in this request.
     $last_read = &drupal_static('drupal_session_last_read');
     $is_changed = !isset($last_read) || $last_read['sid'] != $sid || $last_read['value'] !== $value;
@@ -238,8 +237,6 @@ function _drupal_session_write($sid, $value) {
  * Initializes the session handler, starting a session if needed.
  */
 function drupal_session_initialize() {
-  global $user;
-
   session_set_save_handler('_drupal_session_open', '_drupal_session_close', '_drupal_session_read', '_drupal_session_write', '_drupal_session_destroy', '_drupal_session_garbage_collection');
 
   $is_https = \Drupal::request()->isSecure();
@@ -260,7 +257,7 @@ function drupal_session_initialize() {
     // processes (like drupal_get_token()) needs to know the future
     // session ID in advance.
     $GLOBALS['lazy_session'] = TRUE;
-    $user = drupal_anonymous_user();
+    \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
     // Less random sessions (which are much faster to generate) are used for
     // anonymous users than are generated in drupal_session_regenerate() when
     // a user becomes authenticated.
@@ -301,14 +298,12 @@ function drupal_session_start() {
  * If an anonymous user already have an empty session, destroy it.
  */
 function drupal_session_commit() {
-  global $user;
-
   if (!drupal_save_session()) {
     // We don't have anything to do if we are not allowed to save the session.
     return;
   }
 
-  if ($user->isAnonymous() && empty($_SESSION)) {
+  if (\Drupal::currentUser()->isAnonymous() && empty($_SESSION)) {
     // There is no session data to store, destroy the session if it was
     // previously started.
     if (drupal_session_started()) {
@@ -350,8 +345,6 @@ function drupal_session_started($set = NULL) {
  * @ingroup php_wrappers
  */
 function drupal_session_regenerate() {
-  global $user;
-
   // Nothing to do if we are not allowed to change the session.
   if (!drupal_save_session()) {
     return;
@@ -411,9 +404,9 @@ function drupal_session_regenerate() {
     // Start the session when it doesn't exist yet.
     // Preserve the logged in user, as it will be reset to anonymous
     // by _drupal_session_read.
-    $account = $user;
+    $account = \Drupal::currentUser();
     drupal_session_start();
-    $user = $account;
+    \Drupal::getContainer()->set('current_user', $account);
   }
   date_default_timezone_set(drupal_get_user_timezone());
 }
@@ -427,8 +420,6 @@ function drupal_session_regenerate() {
  *   Session ID.
  */
 function _drupal_session_destroy($sid) {
-  global $user;
-
   // Nothing to do if we are not allowed to change the session.
   if (!drupal_save_session()) {
     return;
@@ -443,7 +434,7 @@ function _drupal_session_destroy($sid) {
   // Reset $_SESSION and $user to prevent a new session from being started
   // in drupal_session_commit().
   $_SESSION = array();
-  $user = drupal_anonymous_user();
+  \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
 
   // Unset the session cookies.
   _drupal_session_delete_cookie(session_name());
@@ -518,7 +509,7 @@ function _drupal_session_garbage_collection($lifetime) {
  *
  * This function allows the caller to temporarily disable writing of
  * session data, should the request end while performing potentially
- * dangerous operations, such as manipulating the global $user object.
+ * dangerous operations, such as manipulating the current user object.
  * See http://drupal.org/node/218104 for usage.
  *
  * @param $status
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 37f04f9..50da011 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -84,7 +84,7 @@ function drupal_theme_access($theme) {
  * Initializes the theme system by loading the theme.
  */
 function drupal_theme_initialize() {
-  global $theme, $user, $theme_key;
+  global $theme, $theme_key;
 
   // If $theme is already set, assume the others are set, too, and do nothing
   if (isset($theme)) {
@@ -1726,8 +1726,7 @@ function theme_table($variables) {
  */
 function theme_mark($variables) {
   $type = $variables['status'];
-  global $user;
-  if ($user->isAuthenticated()) {
+  if (\Drupal::currentUser()->isAuthenticated()) {
     if ($type == MARK_NEW) {
       return ' <span class="marker">' . t('new') . '</span>';
     }
diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
index d3630c4..582bfa3 100644
--- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
@@ -83,8 +83,6 @@ public function applies(Request $request) {
    * {@inheritdoc}
    */
   public function authenticate(Request $request) {
-    global $user;
-
     $account = NULL;
 
     // Iterate the availlable providers.
@@ -112,10 +110,7 @@ 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;
+    \Drupal::getContainer()->set('current_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 f18cd2c..9285422 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessController.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php
@@ -276,7 +276,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/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index 355e560..960020c 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -1815,8 +1815,7 @@ protected function currentUser() {
         $this->currentUser = \Drupal::currentUser();
       }
       else {
-        global $user;
-        $this->currentUser = $user;
+        $this->currentUser = \Drupal::currentUser();
       }
     }
     return $this->currentUser;
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;
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index ca4a607..2c4f7fd 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -20,7 +20,7 @@ class MessageFormController extends ContentEntityFormController {
    * Overrides Drupal\Core\Entity\EntityFormController::form().
    */
   public function form(array $form, array &$form_state) {
-    global $user;
+    $user = \Drupal::currentUser();
     $message = $this->entity;
     $form = parent::form($form, $form_state, $message);
     $form['#attributes']['class'][] = 'contact-form';
@@ -131,7 +131,7 @@ public function preview(array $form, array &$form_state) {
    * Overrides Drupal\Core\Entity\EntityFormController::save().
    */
   public function save(array $form, array &$form_state) {
-    global $user;
+    $user = \Drupal::currentUser();
 
     $language_interface = language(Language::TYPE_INTERFACE);
     $message = $this->entity;
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
index 4621c5c..1842c7c 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
@@ -69,8 +69,6 @@ public function settingsSummary() {
    * {@inheritdoc}
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) {
-    global $user;
-
     $entity = $items->getEntity();
 
     // Prepare the autocomplete route parameters.
@@ -95,7 +93,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
       '#placeholder' => $this->getSetting('placeholder'),
       '#element_validate' => array(array($this, 'elementValidate')),
       // @todo: Use wrapper to get the user if exists or needed.
-      '#autocreate_uid' => isset($entity->uid) ? $entity->uid : $user->id(),
+      '#autocreate_uid' => isset($entity->uid) ? $entity->uid : \Drupal::currentUser()->id(),
     );
 
     return array('target_id' => $element);
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
index a93300e..6dadcf5 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
@@ -120,7 +120,7 @@ public function testSort() {
 
     // Test as a non-admin.
     $normal_user = $this->drupalCreateUser(array('access content'));
-    $GLOBALS['user'] = $normal_user;
+    \Drupal::getContainer()->set('current_user', $normal_user);
 
     $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($instance);
 
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 4962044..151e7f3 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -674,7 +674,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE,
  *   The expanded element.
  */
 function filter_process_format($element) {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // Ensure that children appear as subkeys of this element.
   $element['#tree'] = TRUE;
@@ -868,9 +868,7 @@ function theme_text_format_wrapper($variables) {
  *   - id: Filter ID.
  */
 function _filter_tips($format_id, $long = FALSE) {
-  global $user;
-
-  $formats = filter_formats($user);
+  $formats = filter_formats(\Drupal::currentUser());
 
   $tips = array();
 
diff --git a/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php b/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php
index 182174c..c1de103 100644
--- a/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php
+++ b/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php
@@ -49,7 +49,7 @@ public function testHandlers() {
 
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
-    $GLOBALS['user'] = $account;
+    \Drupal::getContainer()->set('current_user', $account);
 
     db_insert('history')
       ->fields(array(
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
index 262d0a6..874ee90 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
@@ -54,7 +54,7 @@ protected function setUp() {
     // Create a test entity to serialize.
     $this->values = array(
       'name' => $this->randomName(),
-      'user_id' => $GLOBALS['user']->id(),
+      'user_id' => \Drupal::currentUser()->id(),
       'field_test_text' => array(
         'value' => $this->randomName(),
         'format' => 'full_html',
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 2f794b2..2994f4e 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -898,7 +898,8 @@ protected function changeDatabasePrefix() {
    * @see TestBase::tearDown()
    */
   protected function prepareEnvironment() {
-    global $user, $conf;
+    global $conf;
+    $user = \Drupal::currentUser();
     $language_interface = language(Language::TYPE_INTERFACE);
 
     // When running the test runner within a test, back up the original database
@@ -933,7 +934,7 @@ protected function prepareEnvironment() {
     drupal_save_session(FALSE);
     // Run all tests as a anonymous user by default, web tests will replace that
     // during the test set up.
-    $user = drupal_anonymous_user();
+    \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
 
     // Save and clean the shutdown callbacks array because it is static cached
     // and will be changed by the test run. Otherwise it will contain callbacks
@@ -976,7 +977,7 @@ protected function prepareEnvironment() {
 
     $request = Request::create('/');
     $this->container->set('request', $request);
-    $this->container->set('current_user', $GLOBALS['user']);
+    $this->container->set('current_user', \Drupal::currentUser());
 
     \Drupal::setContainer($this->container);
 
@@ -1048,9 +1049,9 @@ protected function rebuildContainer() {
     // DrupalKernel replaces the container in \Drupal::getContainer() with a
     // different object, so we need to replace the instance on this test class.
     $this->container = \Drupal::getContainer();
-    // The global $user is set in TestBase::prepareEnvironment().
+    // The current user is set in TestBase::prepareEnvironment().
     $this->container->set('request', $request);
-    $this->container->set('current_user', $GLOBALS['user']);
+    $this->container->set('current_user', \Drupal::currentUser());
   }
 
   /**
@@ -1065,7 +1066,7 @@ protected function rebuildContainer() {
    * @see TestBase::prepareEnvironment()
    */
   protected function tearDown() {
-    global $user, $conf;
+    global $conf;
 
     // Reset all static variables.
     // Unsetting static variables will potentially invoke destruct methods,
@@ -1143,7 +1144,7 @@ protected function tearDown() {
     $callbacks = $this->originalShutdownCallbacks;
 
     // Restore original user session.
-    $user = $this->originalUser;
+    $this->container->set('current_user', $this->originalUser);
     drupal_save_session(TRUE);
   }
 
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 7541fb2..4466ea2 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -277,7 +277,7 @@ protected function drupalCreateNode(array $settings = array()) {
         $settings['uid'] = $this->loggedInUser->id();
       }
       else {
-        $user = \Drupal::currentUser() ?: $GLOBALS['user'];
+        $user = \Drupal::currentUser();
         $settings['uid'] = $user->id();
       }
     }
@@ -605,7 +605,7 @@ protected function checkPermissions(array $permissions, $reset = FALSE) {
    * If a user is already logged in, then the current user is logged out before
    * logging in the specified user.
    *
-   * Please note that neither the global $user nor the passed-in user object is
+   * Please note that neither the current user nor the passed-in user object is
    * populated with data of the logged in user. If you need full access to the
    * user object after logging in, it must be updated manually. If you also need
    * access to the plain-text password of the user (set by drupalCreateUser()),
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
index 4511346..213bccc 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -94,8 +94,6 @@ function testAdminDefinedFormatDate() {
    * Tests the format_date() function.
    */
   function testFormatDate() {
-    global $user;
-
     $language_interface = language(Language::TYPE_INTERFACE);
 
     $timestamp = strtotime('2007-03-26T00:00:00+00:00');
@@ -127,11 +125,13 @@ function testFormatDate() {
     $edit = array('preferred_langcode' => self::LANGCODE, 'mail' => $test_user->getEmail(), 'timezone' => 'America/Los_Angeles');
     $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save'));
 
-    // Disable session saving as we are about to modify the global $user.
+    // Disable session saving as we are about to modify the current user.
     drupal_save_session(FALSE);
     // Save the original user and language and then replace it with the test user and language.
-    $real_user = $user;
+    $real_user = \Drupal::currentUser();
     $user = user_load($test_user->id(), TRUE);
+    \Drupal::getContainer()->set('current_user', $user);
+
     $real_language = $language_interface->id;
     $language_interface->id = $user->getPreferredLangcode();
     // Simulate a Drupal bootstrap with the logged-in user.
@@ -154,7 +154,7 @@ function testFormatDate() {
     $this->assertIdentical(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
 
     // Restore the original user and language, and enable session saving.
-    $user = $real_user;
+    \Drupal::getContainer()->set('current_user', $real_user);
     $language_interface->id = $real_language;
     // Restore default time zone.
     date_default_timezone_set(drupal_get_user_timezone());
diff --git a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
index 3707bf8..4bf3959 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
@@ -57,8 +57,6 @@ public function testSystemTimezone() {
    * stated timezones.
    */
   public function testDateTimezone() {
-    global $user;
-
     $date_string = '2007-01-31 21:00:00';
 
     // Make sure no site timezone has been set.
@@ -99,11 +97,12 @@ public function testDateTimezone() {
     $edit = array('mail' => $test_user->getEmail(), 'timezone' => 'Asia/Manila');
     $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save'));
 
-    // Disable session saving as we are about to modify the global $user.
+    // Disable session saving as we are about to modify the current user.
     drupal_save_session(FALSE);
     // Save the original user and then replace it with the test user.
     $real_user = $user;
     $user = user_load($test_user->id(), TRUE);
+    \Drupal::getContainer()->set('current_user', $user);
 
     // Simulate a Drupal bootstrap with the logged-in user.
     date_default_timezone_set(drupal_get_user_timezone());
@@ -116,7 +115,7 @@ public function testDateTimezone() {
     $this->assertTrue($timezone == 'Asia/Manila', 'DrupalDateTime uses the user timezone, if configurable timezones are used and it is set.');
 
     // Restore the original user, and enable session saving.
-    $user = $real_user;
+    \Drupal::getContainer()->set('current_user', $real_user);
     // Restore default time zone.
     date_default_timezone_set(drupal_get_user_timezone());
     drupal_save_session(TRUE);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
index 373c90b..38573d6 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
@@ -60,8 +60,9 @@ function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface
    */
   function testEntityAccess() {
     // Set up a non-admin user that is allowed to view test entities.
-    global $user;
     $user = $this->createUser(array('uid' => 2), array('view test entity'));
+    \Drupal::getContainer()->set('current_user', $user);
+
     $entity = entity_create('entity_test', array(
       'name' => 'test',
     ));
@@ -89,8 +90,8 @@ function testEntityAccess() {
    */
   function testEntityAccessDefaultController() {
     // The implementation requires that the global user id can be loaded.
-    global $user;
     $user = $this->createUser(array('uid' => 2));
+    \Drupal::getContainer()->set('current_user', $user);
 
     // Check that the default access controller is used for entities that don't
     // have a specific access controller defined.
@@ -112,8 +113,8 @@ function testEntityAccessDefaultController() {
   function testEntityTranslationAccess() {
 
     // Set up a non-admin user that is allowed to view test entity translations.
-    global $user;
     $user = $this->createUser(array('uid' => 2), array('view test entity translations'));
+    \Drupal::getContainer()->set('current_user', $user);
 
     // Create two test languages.
     foreach (array('foo', 'bar') as $langcode) {
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
index 4344801..edad64a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -32,7 +32,6 @@ function testTokenReplacement() {
     $account = $this->drupalCreateUser();
     $node = $this->drupalCreateNode(array('uid' => $account->id()));
     $node->title = '<blink>Blinking Text</blink>';
-    global $user;
     $language_interface = language(Language::TYPE_INTERFACE);
 
     $source  = '[node:title]';         // Title of the node we passed in
@@ -46,7 +45,7 @@ function testTokenReplacement() {
     $target  = check_plain($node->getTitle());
     $target .= check_plain($account->getUsername());
     $target .= format_interval(REQUEST_TIME - $node->getCreatedTime(), 2, $language_interface->id);
-    $target .= check_plain($user->getUsername());
+    $target .= check_plain(\Drupal::currentUser()->getUsername());
     $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->id);
 
     // Test that the clear parameter cleans out non-existent tokens.
diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php
index eca2eb2..b918749 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -330,7 +330,7 @@ public function validate(array $form, array &$form_state) {
 
       if ($mail_taken) {
         // Format error message dependent on whether the user is logged in or not.
-        if ($GLOBALS['user']->isAuthenticated()) {
+        if (\Drupal::currentUser()->isAuthenticated()) {
           $this->setFormError('mail', $form_state, $this->t('The e-mail address %email is already taken.', array('%email' => $mail)));
         }
         else {
diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php
index 2954df5..8668373 100644
--- a/core/modules/user/lib/Drupal/user/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Entity/User.php
@@ -120,7 +120,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
       // user and recreate the current one.
       if ($this->pass->value != $this->original->pass->value) {
         drupal_session_destroy_uid($this->id());
-        if ($this->id() == $GLOBALS['user']->id()) {
+        if ($this->id() == \Drupal::currentUser()->id()) {
           drupal_session_regenerate();
         }
       }
diff --git a/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
index 3c23086..f90b4bd 100644
--- a/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
@@ -29,7 +29,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
     $path = $request->attributes->get('_system_path');
     if ($site_status == MENU_SITE_OFFLINE) {
       // If the site is offline, log out unprivileged users.
-      if ($GLOBALS['user']->isAuthenticated() && !user_access('access site in maintenance mode')) {
+      if (\Drupal::currentUser()->isAuthenticated() && !user_access('access site in maintenance mode')) {
         user_logout();
         // Redirect to homepage.
         $event->setResponse(new RedirectResponse(url('<front>', array('absolute' => TRUE))));
@@ -56,7 +56,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
         }
       }
     }
-    if ($GLOBALS['user']->isAuthenticated()) {
+    if (\Drupal::currentUser()->isAuthenticated()) {
       if ($path == 'user/login') {
         // If user is logged in, redirect to 'user' instead of giving 403.
         $event->setResponse(new RedirectResponse(url('user', array('absolute' => TRUE))));
@@ -64,7 +64,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) {
       }
       if ($path == 'user/register') {
         // Authenticated user should be redirected to user edit page.
-        $event->setResponse(new RedirectResponse(url('user/' . $GLOBALS['user']->id() . '/edit', array('absolute' => TRUE))));
+        $event->setResponse(new RedirectResponse(url('user/' . \Drupal::currentUser()->id() . '/edit', array('absolute' => TRUE))));
         return;
       }
     }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
index b404ba0..75fa5f5 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
@@ -60,7 +60,7 @@ public static function create(ContainerInterface $container, array $configuratio
    * {@inheritdoc}
    */
   public function executeMultiple(array $entities) {
-    $this->tempStoreFactory->get('user_user_operations_cancel')->set($GLOBALS['user']->id(), $entities);
+    $this->tempStoreFactory->get('user_user_operations_cancel')->set(\Drupal::currentUser()->id(), $entities);
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
index e763bae..f1d987b 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
@@ -10,7 +10,7 @@
 use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
 
 /**
- * Default argument plugin to extract the global $user
+ * Default argument plugin to extract the current user
  *
  * This plugin actually has no options so it odes not need to do a great deal.
  *
@@ -22,8 +22,7 @@
 class CurrentUser extends ArgumentDefaultPluginBase {
 
   public function getArgument() {
-    global $user;
-    return $user->id();
+    return \Drupal::currentUser()->id();
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
index d385236..d7c3701 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
@@ -109,21 +109,21 @@ public function validateArgument($argument) {
     // However, is_integer() will always fail, since $argument is a string.
     if (is_numeric($argument) && $argument == (int)$argument) {
       if ($type == 'uid' || $type == 'either') {
-        if ($argument == $GLOBALS['user']->id()) {
+        if ($argument == \Drupal::currentUser()->id()) {
           // If you assign an object to a variable in PHP, the variable
           // automatically acts as a reference, not a copy, so we use
           // clone to ensure that we don't actually mess with the
-          // real global $user object.
-          $account = clone $GLOBALS['user'];
+          // real current user object.
+          $account = clone \Drupal::currentUser();
         }
         $condition = 'uid';
       }
     }
     else {
       if ($type == 'name' || $type == 'either') {
-        $name = $GLOBALS['user']->getUserName() ?: \Drupal::config('user.settings')->get('anonymous');
+        $name = \Drupal::currentUser()->getUserName() ?: \Drupal::config('user.settings')->get('anonymous');
         if ($argument == $name) {
-          $account = clone $GLOBALS['user'];
+          $account = clone \Drupal::currentUser();
         }
         $condition = 'name';
       }
diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php
index 38612a2..5a2fcc2 100644
--- a/core/modules/user/lib/Drupal/user/RegisterFormController.php
+++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php
@@ -18,7 +18,6 @@ class RegisterFormController extends AccountFormController {
    * Overrides Drupal\Core\Entity\EntityFormController::form().
    */
   public function form(array $form, array &$form_state) {
-    global $user;
     $account = $this->entity;
 
     $admin = user_access('administer users');
@@ -32,8 +31,8 @@ public function form(array $form, array &$form_state) {
     );
 
     // If we aren't admin but already logged on, go to the user page instead.
-    if (!$admin && $user->isAuthenticated()) {
-      return new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE)));
+    if (!$admin && \Drupal::currentUser()->isAuthenticated()) {
+      return new RedirectResponse(url('user/' . \Drupal::currentUser()->id(), array('absolute' => TRUE)));
     }
 
     $form['#attached']['library'][] = array('system', 'jquery.cookie');
diff --git a/core/modules/user/lib/Drupal/user/TempStoreFactory.php b/core/modules/user/lib/Drupal/user/TempStoreFactory.php
index 45f421e..28d4147 100644
--- a/core/modules/user/lib/Drupal/user/TempStoreFactory.php
+++ b/core/modules/user/lib/Drupal/user/TempStoreFactory.php
@@ -61,7 +61,7 @@ function get($collection, $owner = NULL) {
     // Use the currently authenticated user ID or the active user ID unless
     // the owner is overridden.
     if (!isset($owner)) {
-      $owner = $GLOBALS['user']->id() ?: session_id();
+      $owner = \Drupal::currentUser()->id() ?: session_id();
     }
 
     // Store the data for this collection in the database.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index cc706ba..13172de 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -57,7 +57,7 @@ function testUserTokenReplacement() {
     $this->drupalLogin($user2);
 
     $account = user_load($user1->id());
-    $global_account = user_load($GLOBALS['user']->id());
+    $global_account = user_load(\Drupal::currentUser()->id());
 
     // Generate and test sanitized tokens.
     $tests = array();
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php
index 654d1d7..655ae61 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php
@@ -33,17 +33,17 @@ public function test_plugin_argument_default_current_user() {
 
     // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser.
     $this->drupalLogin($account);
-    global $user;
-    $admin = $user;
+
+    $admin = \Drupal::currentUser();
     drupal_save_session(FALSE);
-    $user = $account;
+    \Drupal::getContainer()->set('current_user', $account);
 
     $view = views_get_view('test_plugin_argument_default_current_user');
     $view->initHandlers();
 
     $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.');
     // Switch back.
-    $user = $admin;
+    \Drupal::getContainer()->set('current_user', $admin);
     drupal_save_session(TRUE);
   }
 
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index a194b00..950b89d 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -516,8 +516,6 @@ function user_update_8009(&$sandbox) {
  * Create user picture field.
  */
 function user_update_8011() {
-  global $user;
-
   // User pictures can only be migrated to the new user picture image field
   // if Image module is installed.
   if (!\Drupal::moduleHandler()->moduleExists('image')) {
@@ -548,7 +546,7 @@ function user_update_8011() {
         'uri' => $destination,
       ))
       ->fields(array(
-        'uid' => $user->id(),
+        'uid' => \Drupal::currentUser()->id(),
         'status' => FILE_STATUS_PERMANENT,
         'filename' => drupal_basename($destination),
         'uuid' => $uuid->generate(),
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index f551063..5c20324 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -266,8 +266,8 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) {
 /**
  * Loads a user object.
  *
- * Drupal has a global $user object, which represents the currently-logged-in
- * user. So to avoid confusion and to avoid clobbering the global $user object,
+ * Drupal has a currend user object, which represents the currently-logged-in
+ * user. So to avoid confusion and to avoid clobbering the current user object,
  * it is a good idea to assign the result of this function to a different local
  * variable, generally $account. If you actually do want to act as the user you
  * are loading, it is essential to call drupal_save_session(FALSE); first.
@@ -431,12 +431,10 @@ function _user_role_permissions_update($roles) {
  *   \Drupal\Core\Session\AccountInterface::hasPermission()
  */
 function user_access($string, AccountInterface $account = NULL) {
-  global $user;
-
   if (!isset($account)) {
     // In the installer request session is not set, so we have to fall back
-    // to the global $user. In all other cases the session key is preferred.
-    $account = \Drupal::currentUser() ?: $user;
+    // to the current user. In all other cases the session key is preferred.
+    $account = \Drupal::currentUser();
   }
 
   return $account->hasPermission($string);
@@ -580,7 +578,7 @@ function user_format_name(AccountInterface $account) {
  * @see user_user_logout()
  */
 function user_template_preprocess_default_variables_alter(&$variables) {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // If this function is called from the installer after Drupal has been
   // installed then $user will not be set.
@@ -687,7 +685,7 @@ function theme_username($variables) {
  */
 function user_is_anonymous() {
   // Menu administrators can see items for anonymous when administering.
-  return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
+  return \Drupal::currentUser()->isAnonymous() || !empty($GLOBALS['menu_admin']);
 }
 
 /**
@@ -699,7 +697,7 @@ function user_is_anonymous() {
  * @deprecated Use \Drupal\Core\Session\UserSession::isAuthenticated().
  */
 function user_is_logged_in() {
-  return $GLOBALS['user']->isAuthenticated();
+  return \Drupal::currentUser()->isAuthenticated();
 }
 
 /**
@@ -874,7 +872,7 @@ function user_uid_only_optional_to_arg($arg) {
  */
 function user_uid_optional_load($uid = NULL) {
   if (!isset($uid)) {
-    $uid = $GLOBALS['user']->id();
+    $uid = \Drupal::currentUser()->id();
   }
   return user_load($uid);
 }
@@ -888,7 +886,7 @@ function user_uid_optional_to_arg($arg) {
   // Give back the current user uid when called from eg. tracker, aka.
   // with an empty arg. Also use the current user uid when called from
   // the menu with a % for the current account link.
-  return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
+  return empty($arg) || $arg == '%' ? \Drupal::currentUser()->id() : $arg;
 }
 
 /**
@@ -898,7 +896,7 @@ function user_uid_optional_to_arg($arg) {
  * authenticated users are expected to see "My account".
  */
 function user_menu_title() {
-  if ($GLOBALS['user']->isAnonymous()) {
+  if (\Drupal::currentUser()->isAnonymous()) {
     switch (current_path()) {
       case 'user' :
       case 'user/login' :
@@ -961,7 +959,7 @@ function user_authenticate($name, $password) {
  * session, saves the login timestamp, calls hook_user_login(), and generates a
  * new session.
  *
- * The global $user object is replaced with the passed in account.
+ * The current user object is replaced with the passed in account.
  *
  * @param \Drupal\user\UserInterface $account
  *   The account to log in.
@@ -969,8 +967,7 @@ function user_authenticate($name, $password) {
  * @see hook_user_login()
  */
 function user_login_finalize(UserInterface $account) {
-  global $user;
-  $user = $account;
+  \Drupal::getContainer()->set('current_user', $account);
   watchdog('user', 'Session opened for %name.', array('%name' => $user->getUsername()));
   // Update the user table timestamp noting user has logged in.
   // This is also used to invalidate one-time login links.
@@ -1100,8 +1097,6 @@ function user_pass_rehash($password, $timestamp, $login) {
  * @see _user_cancel()
  */
 function user_cancel($edit, $uid, $method) {
-  global $user;
-
   $account = user_load($uid);
 
   if (!$account) {
@@ -1134,7 +1129,7 @@ function user_cancel($edit, $uid, $method) {
   );
 
   // After cancelling account, ensure that user is logged out.
-  if ($account->id() == $user->id()) {
+  if ($account->id() == \Drupal::currentUser()->id()) {
     // Batch API stores data in the session, so use the finished operation to
     // manipulate the current user's session id.
     $batch['finished'] = '_user_cancel_session_regenerate';
@@ -1155,8 +1150,6 @@ function user_cancel($edit, $uid, $method) {
  * @see user_cancel()
  */
 function _user_cancel($edit, $account, $method) {
-  global $user;
-
   switch ($method) {
     case 'user_cancel_block':
     case 'user_cancel_block_unpublish':
@@ -1187,8 +1180,8 @@ function _user_cancel($edit, $account, $method) {
   // their session though, as we might have information in it, and we can't
   // regenerate it because batch API uses the session ID, we will regenerate it
   // in _user_cancel_session_regenerate().
-  if ($account->id() == $user->id()) {
-    $user = drupal_anonymous_user();
+  if ($account->id() == \Drupal::currentUser()->id()) {
+    \Drupal::getContainer()->set('current_user', drupal_anonymous_user());
   }
 
   // Clear the cache for anonymous users.
@@ -1711,8 +1704,6 @@ function user_form_pre_render_password_confirm($element) {
   );
 
   if (\Drupal::config('user.settings')->get('password_strength')) {
-
-    global $user;
     $password_settings['showStrengthIndicator'] = TRUE;
     $password_settings += array(
       'strengthTitle' => t('Password strength:'),
@@ -1727,7 +1718,7 @@ function user_form_pre_render_password_confirm($element) {
       'fair' => t('Fair'),
       'good' => t('Good'),
       'strong' => t('Strong'),
-      'username' => $user->getUsername(),
+      'username' => \Drupal::currentUser()->getUsername(),
     );
   }
 
@@ -1809,7 +1800,7 @@ function user_file_download_access($field, EntityInterface $entity, File $file)
  * Implements hook_toolbar().
  */
 function user_toolbar() {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // Add logout & user account links or login link.
   if ($user->isAuthenticated()) {
@@ -1928,7 +1919,7 @@ function user_library_info() {
  * Logs the current user out.
  */
 function user_logout() {
-  global $user;
+  $user = \Drupal::currentUser();
 
   watchdog('user', 'Session closed for %name.', array('%name' => $user->getUsername()));
 
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 2977253..c4425b9 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -17,7 +17,7 @@
  * @deprecated Use \Drupal\user\Form\UserForm::resetPass()
  */
 function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // When processing the one-time login link, we have to make sure that a user
   // isn't already logged in.
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 5412a38..e3c22f2 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -125,7 +125,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
   }
 
   if ($type == 'current-user') {
-    $account = user_load($GLOBALS['user']->id());
+    $account = user_load(\Drupal::currentUser()->id());
     $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options);
   }
 
diff --git a/core/modules/user/user.views_execution.inc b/core/modules/user/user.views_execution.inc
index 622cdbf..c9a3f1d 100644
--- a/core/modules/user/user.views_execution.inc
+++ b/core/modules/user/user.views_execution.inc
@@ -13,6 +13,5 @@
  * Allow replacement of current userid so we can cache these queries.
  */
 function user_views_query_substitutions(ViewExecutable $view) {
-  global $user;
-  return array('***CURRENT_USER***' => $user->id());
+  return array('***CURRENT_USER***' => \Drupal::currentUser()->id());
 }
diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh
index 30c61a2..b7d7101 100644
--- a/core/scripts/generate-d7-content.sh
+++ b/core/scripts/generate-d7-content.sh
@@ -257,11 +257,11 @@
   // Add some votes
   $node = node_load($node->nid);
   $choices = array_keys($node->choice);
-  $original_user = $GLOBALS['user'];
+  $original_user = \Drupal::currentUser();
   for ($v = 0; $v < ($i % 4); $v++) {
     drupal_static_reset('ip_address');
     $_SERVER['REMOTE_ADDR'] = "127.0.$v.1";
-    $GLOBALS['user'] = drupal_anonymous_user();// We should have already allowed anon to vote.
+    \Drupal::getContainer()->set('current_user', drupal_anonymous_user()); // We should have already allowed anon to vote.
     $c = $v % $nbchoices;
     $form_state = array();
     $form_state['values']['choice'] = $choices[$c];
