diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index d9f44da..9913cdc 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1550,7 +1550,7 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG
     $in_error_state = TRUE;
 
     // The user object may not exist in all conditions, so 0 is substituted if needed.
-    $user_uid = isset($user->uid) ? $user->uid : 0;
+    $user_uid = isset($user) ? $user->id() : 0;
 
     // Prepare the fields to be logged
     $log_entry = array(
@@ -1898,7 +1898,7 @@ function drupal_get_user_timezone() {
   global $user;
   $config = config('system.timezone');
 
-  if ($user && $config->get('user.configurable') && $user->uid && $user->timezone) {
+  if ($user && $config->get('user.configurable') && $user->id() && $user->timezone) {
     return $user->timezone;
   }
   else {
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 3852870..be29965 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3084,7 +3084,7 @@ function drupal_get_token($value = '') {
  */
 function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
   global $user;
-  return (($skip_anonymous && $user->uid == 0) || ($token == drupal_get_token($value)));
+  return (($skip_anonymous && $user->id() == 0) || ($token == drupal_get_token($value)));
 }
 
 /**
@@ -4182,7 +4182,7 @@ function drupal_render_cid_parts($granularity = NULL) {
       $cid_parts[] = 'r.' . implode(',', $user->roles);
     }
     elseif ($granularity & DRUPAL_CACHE_PER_USER) {
-      $cid_parts[] = "u.$user->uid";
+      $cid_parts[] = 'u.' . $user->id();
     }
 
     if ($granularity & DRUPAL_CACHE_PER_PAGE) {
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 58644ff..1af50cc 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -1123,7 +1123,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
     }
     // Begin building file entity.
     $values = array(
-      'uid' => $user->uid,
+      'uid' => $user->id(),
       'status' => 0,
       'filename' => trim(drupal_basename($name, '.')),
       'uri' => $uploaded_files['files']['tmp_name'][$form_field_name][$i],
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 7d1a253..d602d54 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -546,7 +546,7 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
 function form_get_cache($form_build_id, &$form_state) {
   if ($form = Drupal::keyValueExpirable('form')->get($form_build_id)) {
     global $user;
-    if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
+    if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && $user->isAnonymous())) {
       if ($stored_form_state = Drupal::keyValueExpirable('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state = $stored_form_state + $form_state;
@@ -578,7 +578,7 @@ function form_set_cache($form_build_id, $form, $form_state) {
 
   // Cache form structure.
   if (isset($form)) {
-    if ($GLOBALS['user']->uid) {
+    if ($GLOBALS['user']->isAuthenticated()) {
       $form['#cache_token'] = drupal_get_token();
     }
     Drupal::keyValueExpirable('form')->setWithExpire($form_build_id, $form, $expire);
@@ -1069,7 +1069,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
   // tokens are session-bound and forms displayed to anonymous users are very
   // likely cached, we cannot assign a token for them.
   // During installation, there is no $user yet.
-  if (!empty($user->uid) && !$form_state['programmed']) {
+  if ($user && $user->isAuthenticated() && !$form_state['programmed']) {
     // Form constructors may explicitly set #token to FALSE when cross site
     // request forgery is irrelevant to the form, such as search forms.
     if (isset($form['#token']) && $form['#token'] === FALSE) {
@@ -4888,7 +4888,7 @@ function _drupal_form_send_response(Response $response) {
  * $batch = array(
  *   'title' => t('Exporting'),
  *   'operations' => array(
- *     array('my_function_1', array($account->uid, 'story')),
+ *     array('my_function_1', array($account->id(), 'story')),
  *     array('my_function_2', array()),
  *   ),
  *   'finished' => 'my_finished_callback',
diff --git a/core/includes/language.inc b/core/includes/language.inc
index 5f7d823..e63acaa 100644
--- a/core/includes/language.inc
+++ b/core/includes/language.inc
@@ -470,7 +470,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->uid || $method['cache'] == variable_get('cache', 0);
+    $cache = !isset($method['cache']) || $user->isAuthenticated() || $method['cache'] == variable_get('cache', 0);
     $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 40e495f..572ac21 100644
--- a/core/includes/session.inc
+++ b/core/includes/session.inc
@@ -115,7 +115,7 @@ function _drupal_session_read($sid) {
   if ($values && $values['uid'] > 0 && $values['status'] == 1) {
     $user = new UserSession($values);
     // Add roles element to $user.
-    $rids = db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchCol();
+    $rids = db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->id()))->fetchCol();
     $user->roles = array_merge(array(DRUPAL_AUTHENTICATED_RID), $rids);
   }
   elseif ($user) {
@@ -180,7 +180,7 @@ function _drupal_session_write($sid, $value) {
     if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > settings()->get('session_write_interval', 180)) {
       // Either ssid or sid or both will be added from $key below.
       $fields = array(
-        'uid' => $user->uid,
+        'uid' => $user->id(),
         'hostname' => Drupal::request()->getClientIP(),
         'session' => $value,
         'timestamp' => REQUEST_TIME,
@@ -214,12 +214,12 @@ function _drupal_session_write($sid, $value) {
     }
 
     // Likewise, do not update access time more than once per 180 seconds.
-    if ($user->uid && REQUEST_TIME - $user->access > settings()->get('session_write_interval', 180)) {
+    if ($user->isAuthenticated() && REQUEST_TIME - $user->access > settings()->get('session_write_interval', 180)) {
       db_update('users')
         ->fields(array(
           'access' => REQUEST_TIME
         ))
-        ->condition('uid', $user->uid)
+        ->condition('uid', $user->id())
         ->execute();
     }
 
@@ -254,7 +254,7 @@ function drupal_session_initialize() {
     // anonymous users not use a session cookie unless something is stored in
     // $_SESSION. This allows HTTP proxies to cache anonymous pageviews.
     drupal_session_start();
-    if (!empty($user->uid) || !empty($_SESSION)) {
+    if ($user->isAuthenticated() || !empty($_SESSION)) {
       drupal_page_is_cacheable(FALSE);
     }
   }
@@ -312,7 +312,7 @@ function drupal_session_commit() {
     return;
   }
 
-  if (empty($user->uid) && empty($_SESSION)) {
+  if ($user->isAnonymous() && empty($_SESSION)) {
     // There is no session data to store, destroy the session if it was
     // previously started.
     if (drupal_session_started()) {
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 4635bb7..5639a5c 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2229,7 +2229,7 @@ function template_preprocess_tablesort_indicator(&$variables) {
 function theme_mark($variables) {
   $type = $variables['status'];
   global $user;
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     if ($type == MARK_NEW) {
       return ' <span class="marker">' . t('new') . '</span>';
     }
diff --git a/core/lib/Drupal/Core/Entity/Field/Field.php b/core/lib/Drupal/Core/Entity/Field/Field.php
index 3948ddf..132580f 100644
--- a/core/lib/Drupal/Core/Entity/Field/Field.php
+++ b/core/lib/Drupal/Core/Entity/Field/Field.php
@@ -164,8 +164,8 @@ public function __unset($property_name) {
    */
   public function access($operation = 'view', AccountInterface $account = NULL) {
     global $user;
-    if (!isset($account) && $user->uid) {
-      $account = user_load($user->uid);
+    if (!isset($account)) {
+      $account = $user;
     }
     // Get the default access restriction that lives within this field.
     $access = $this->defaultAccess($operation, $account);
diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php
index 1dbc13c..3771437 100644
--- a/core/lib/Drupal/Core/Session/AccountInterface.php
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -55,4 +55,63 @@ public function getSecureSessionId();
    */
   public function getSessionData();
 
+  /**
+   * Returns TRUE if the account is authenticated.
+   *
+   * @return bool
+   *   TRUE if the account is authenticated.
+   */
+  public function isAuthenticated();
+
+  /**
+   * Returns TRUE if the account is anonymous.
+   *
+   * @return bool
+   *   TRUE if the account is anonymous.
+   */
+  public function isAnonymous();
+
+  /**
+   * Returns the preferred language code of the account.
+   *
+   * @param string $default
+   *   (optional) Default language code to return if the account
+   *   has no valid language, defaults to the site default language.
+   *
+   * @return string
+   *   The language code that is preferred by the account.
+   */
+  public function getPreferredLangcode($default = NULL);
+
+  /**
+   * Returns the preferred administrative language code of the account.
+   *
+   * Defines which language is used on administrative pages.
+   *
+   * @param string $default
+   *   (optional) Default language code to return if the account
+   *   has no valid language, defaults to the site default language.
+   *
+   * @return string
+   *   The language code that is preferred by the account.
+   */
+  public function getPreferredAdminLangcode($default = NULL);
+
+  /**
+   * Returns the username of this account.
+   *
+   * By default, the passed-in object's 'name' property is used if it exists, or
+   * else, the site-defined value for the 'anonymous' variable. However, a module
+   * may override this by implementing
+   * hook_user_format_name_alter(&$name, $account).
+   *
+   * @see hook_user_format_name_alter()
+   *
+   * @return
+   *   An unsanitized string with the username to display. The code receiving
+   *   this result must ensure that check_plain() is called on it before it is
+   *   printed to the page.
+   */
+  public function getUsername();
+
 }
diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php
index 300cd8f..41d55fc 100644
--- a/core/lib/Drupal/Core/Session/UserSession.php
+++ b/core/lib/Drupal/Core/Session/UserSession.php
@@ -66,6 +66,27 @@ class UserSession implements AccountInterface {
   public $timestamp;
 
   /**
+   * The name of this account.
+   *
+   * @var string
+   */
+  public $name;
+
+  /**
+   * The preferred language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_langcode;
+
+  /**
+   * The preferred administrative language code of the account.
+   *
+   * @var string
+   */
+  protected $preferred_admin_langcode;
+
+  /**
    * Constructs a new user session.
    *
    * @param array $values
@@ -112,4 +133,53 @@ public function getSessionId() {
     return $this->sid;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->uid > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->uid == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredLangcode($default = NULL) {
+    $language_list = language_list();
+    if (!empty($this->preferred_langcode) && isset($language_list[$this->preferred_langcode])) {
+      return $language_list[$this->preferred_langcode]->id;
+    }
+    else {
+      return $default ? $default : language_default()->id;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredAdminLangcode($default = NULL) {
+    $language_list = language_list();
+    if (!empty($this->preferred_admin_langcode) && isset($language_list[$this->preferred_admin_langcode])) {
+      return $language_list[$this->preferred_admin_langcode]->id;
+    }
+    else {
+      return $default ? $default : language_default()->id;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getUsername() {
+    $name = $this->name ?: \Drupal::config('user.settings')->get('anonymous');
+    \Drupal::moduleHandler()->alter('user_format_name', $name, $this);
+    return $name;
+  }
+
 }
diff --git a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php
index 921b91a..45f38aa 100644
--- a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php
+++ b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php
@@ -86,7 +86,7 @@ public function execute($entity = NULL) {
     $recipient_accounts = $this->storageController->loadByProperties(array('mail' => $recipient));
     $recipient_account = reset($recipient_accounts);
     if ($recipient_account) {
-      $langcode = user_preferred_langcode($recipient_account);
+      $langcode = $recipient_account->getPreferredLangcode();
     }
     else {
       $langcode = language_default()->id;
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 321f584..ed2a6e8 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -296,7 +296,7 @@ function _block_get_renderable_region($list = array()) {
   // the regular 'roles define permissions' schema, it brings too many
   // chances of having unwanted output get in the cache and later be served
   // to other users. We therefore exclude user 1 from block caching.
-  $not_cacheable = $GLOBALS['user']->uid == 1 ||
+  $not_cacheable = $GLOBALS['user']->id() == 1 ||
     count(module_implements('node_grants')) ||
     !\Drupal::request()->isMethodSafe();
 
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index 75bcb39..6ef7d25 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -49,7 +49,7 @@ function testBlockVisibility() {
     $this->drupalGet('user');
     $this->assertNoText($title, 'Block was not displayed according to block visibility rules.');
 
-    $this->drupalGet('USER/' . $this->adminUser->uid);
+    $this->drupalGet('USER/' . $this->adminUser->id());
     $this->assertNoText($title, 'Block was not displayed according to block visibility rules regardless of path case.');
 
     // Confirm that the block is not displayed to anonymous users.
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 604cb93..4b3f1e7 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1252,7 +1252,7 @@ function comment_node_search_result(EntityInterface $node) {
 function comment_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
-      $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->uid));
+      $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
       foreach ($comments as $comment) {
         $comment->status->value = 0;
         $comment->save();
@@ -1260,7 +1260,7 @@ function comment_user_cancel($edit, $account, $method) {
       break;
 
     case 'user_cancel_reassign':
-      $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->uid));
+      $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
       foreach ($comments as $comment) {
         $comment->uid->target_id = 0;
         $comment->save();
@@ -1273,7 +1273,7 @@ function comment_user_cancel($edit, $account, $method) {
  * Implements hook_user_predelete().
  */
 function comment_user_predelete($account) {
-  $cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
+  $cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->id()))->fetchCol();
   entity_delete_multiple('comment', $cids);
 }
 
@@ -1325,7 +1325,7 @@ function comment_load($cid, $reset = FALSE) {
 function comment_num_new($nid, $timestamp = 0) {
   global $user;
 
-  if ($user->uid && module_exists('history')) {
+  if ($user->isAuthenticated() && module_exists('history')) {
     // Retrieve the timestamp at which the current user last viewed this node.
     if (!$timestamp) {
       $timestamp = history_read($nid);
@@ -1423,12 +1423,12 @@ function comment_preview(Comment $comment) {
     if (!empty($comment->name->value)) {
       $account = user_load_by_name($comment->name->value);
     }
-    elseif ($user->uid && empty($comment->is_anonymous)) {
+    elseif ($user->isAuthenticated() && empty($comment->is_anonymous)) {
       $account = $user;
     }
 
-    if (!empty($account->uid)) {
-      $comment->uid->target_id = $account->uid;
+    if ($account->id()) {
+      $comment->uid->target_id = $account->id();
       $comment->name->value = check_plain($account->name);
     }
     elseif (empty($comment->name->value)) {
@@ -1610,10 +1610,10 @@ function template_preprocess_comment(&$variables) {
     $variables['attributes']['class'][] = 'by-anonymous';
   }
   else {
-    if ($comment->uid->target_id == $variables['node']->uid) {
+    if ($comment->uid->target_id == $variables['node']->id()) {
       $variables['attributes']['class'][] = 'by-node-author';
     }
-    if ($comment->uid->target_id == $variables['user']->uid) {
+    if ($comment->uid->target_id == $variables['user']->id()) {
       $variables['attributes']['class'][] = 'by-viewer';
     }
   }
@@ -1640,7 +1640,7 @@ function theme_comment_post_forbidden($variables) {
   // comments only has to query the database once for all the links.
   $authenticated_post_comments = &drupal_static(__FUNCTION__, NULL);
 
-  if (!$user->uid) {
+  if ($user->isAnonymous()) {
     if (!isset($authenticated_post_comments)) {
       // We only output a link if we are certain that users will get permission
       // to post comments by logging in.
diff --git a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php
index 4749428..da728d5 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php
@@ -32,7 +32,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
         break;
 
       case 'update':
-        return ($account->uid && $account->uid == $entity->uid->value && $entity->status->value == COMMENT_PUBLISHED && user_access('edit own comments', $account)) || user_access('administer comments', $account);
+        return ($account->id() && $account->id() == $entity->uid->value && $entity->status->value == COMMENT_PUBLISHED && user_access('edit own comments', $account)) || user_access('administer comments', $account);
         break;
 
       case 'delete':
diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php
index 0584ae3..2264290 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php
@@ -31,7 +31,7 @@ public function form(array $form, array &$form_state) {
     $anonymous_contact = variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT);
     $is_admin = $comment->id() && user_access('administer comments');
 
-    if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
+    if (!$user->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
       $form['#attached']['library'][] = array('system', 'jquery.cookie');
       $form['#attributes']['class'][] = 'user-info-from-cookie';
     }
@@ -65,7 +65,7 @@ public function form(array $form, array &$form_state) {
       $date = (!empty($comment->date) ? $comment->date : new DrupalDateTime($comment->created->value));
     }
     else {
-      if ($user->uid) {
+      if ($user->isAuthenticated()) {
         $author = $user->name;
       }
       else {
@@ -80,7 +80,7 @@ public function form(array $form, array &$form_state) {
       '#type' => 'textfield',
       '#title' => t('Your name'),
       '#default_value' => $author,
-      '#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
+      '#required' => ($user->isAnonymous() && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
       '#maxlength' => 60,
       '#size' => 30,
     );
@@ -89,7 +89,7 @@ public function form(array $form, array &$form_state) {
       $form['author']['name']['#description'] = t('Leave blank for %anonymous.', array('%anonymous' => config('user.settings')->get('anonymous')));
       $form['author']['name']['#autocomplete_path'] = 'user/autocomplete';
     }
-    elseif ($user->uid) {
+    elseif ($user->isAuthenticated()) {
       $form['author']['name']['#type'] = 'item';
       $form['author']['name']['#value'] = $form['author']['name']['#default_value'];
       $username = array(
@@ -104,11 +104,11 @@ public function form(array $form, array &$form_state) {
       '#type' => 'email',
       '#title' => t('E-mail'),
       '#default_value' => $comment->mail->value,
-      '#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
+      '#required' => ($user->isAnonymous() && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
       '#maxlength' => 64,
       '#size' => 30,
       '#description' => t('The content of this field is kept private and will not be shown publicly.'),
-      '#access' => $is_admin || (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
+      '#access' => $is_admin || ($user->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
     );
 
     $form['author']['homepage'] = array(
@@ -117,7 +117,7 @@ public function form(array $form, array &$form_state) {
       '#default_value' => $comment->homepage->value,
       '#maxlength' => 255,
       '#size' => 30,
-      '#access' => $is_admin || (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
+      '#access' => $is_admin || ($user->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
     );
 
     // Add administrative comment publishing options.
@@ -151,7 +151,7 @@ public function form(array $form, array &$form_state) {
     // Used for conditional validation of author fields.
     $form['is_anonymous'] = array(
       '#type' => 'value',
-      '#value' => ($comment->id() ? !$comment->uid->target_id : !$user->uid),
+      '#value' => ($comment->id() ? !$comment->uid->target_id : $user->isAnonymous()),
     );
 
     // Make the comment inherit the current content language unless specifically
@@ -215,7 +215,7 @@ public function validate(array $form, array &$form_state) {
     if (!empty($form_state['values']['cid'])) {
       // Verify the name in case it is being changed from being anonymous.
       $account = user_load_by_name($form_state['values']['name']);
-      $form_state['values']['uid'] = $account ? $account->uid : 0;
+      $form_state['values']['uid'] = $account ? $account->id() : 0;
 
       $date = $form_state['values']['date'];
       if ($date instanceOf DrupalDateTime && $date->hasErrors()) {
@@ -269,7 +269,7 @@ public function submit(array $form, array &$form_state) {
     // @todo Too fragile. Should be prepared and stored in comment_form()
     // already.
     if (!$comment->is_anonymous && !empty($comment->name->value) && ($account = user_load_by_name($comment->name->value))) {
-      $comment->uid->target_id = $account->uid;
+      $comment->uid->target_id = $account->id();
     }
     // If the comment was posted by an anonymous user and no author name was
     // required, use "Anonymous" by default.
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
index 700b629..27dbf17 100644
--- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
@@ -301,7 +301,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
       }
       // We test the value with '===' because we need to modify anonymous
       // users as well.
-      if ($this->uid->target_id === $user->uid && $user->uid) {
+      if ($this->uid->target_id === $user->id() && $user->isAuthenticated()) {
         $this->name->value = $user->name;
       }
       // Add the values which aren't passed into the function.
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php
index c19b84c..0c7fbff 100644
--- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php
@@ -93,7 +93,7 @@ public function query() {
 
   public function preRender(&$values) {
     global $user;
-    if (!$user->uid || empty($values)) {
+    if ($user->isAnonymous() || empty($values)) {
       return;
     }
 
@@ -114,7 +114,7 @@ public function preRender(&$values) {
         LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN (:nids)
         AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp), :timestamp) AND c.status = :status GROUP BY n.nid', array(
           ':status' => COMMENT_PUBLISHED,
-          ':h_uid' => $user->uid,
+          ':h_uid' => $user->id(),
           ':nids' => $nids,
           ':timestamp' => HISTORY_READ_LIMIT,
         ));
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
index 8b07aec..2b506ce 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
@@ -38,8 +38,8 @@ function setUp() {
   function testCommentClasses() {
     // Create all permutations for comments, users, and nodes.
     $parameters = array(
-      'node_uid' => array(0, $this->web_user->uid),
-      'comment_uid' => array(0, $this->web_user->uid, $this->admin_user->uid),
+      'node_uid' => array(0, $this->web_user->id()),
+      'comment_uid' => array(0, $this->web_user->id(), $this->admin_user->id()),
       'comment_status' => array(COMMENT_PUBLISHED, COMMENT_NOT_PUBLISHED),
       'user' => array('anonymous', 'authenticated', 'admin'),
     );
@@ -72,12 +72,12 @@ function testCommentClasses() {
 
         case 'authenticated':
           $this->drupalLogin($this->web_user);
-          $case['user_uid'] = $this->web_user->uid;
+          $case['user_uid'] = $this->web_user->id();
           break;
 
         case 'admin':
           $this->drupalLogin($this->admin_user);
-          $case['user_uid'] = $this->admin_user->uid;
+          $case['user_uid'] = $this->admin_user->id();
           break;
       }
       // Request the node with the comment.
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
index 8d7a472..ed1a528 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
@@ -81,7 +81,7 @@ function testCommentInterface() {
     // Test changing the comment author to a verified user.
     $this->drupalGet('comment/' . $comment->id() . '/edit');
     $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->subject->value, array('name' => $this->web_user->name));
-    $this->assertTrue($comment->name->value == $this->web_user->name && $comment->uid->target_id == $this->web_user->uid, 'Comment author successfully changed to a registered user.');
+    $this->assertTrue($comment->name->value == $this->web_user->name && $comment->uid->target_id == $this->web_user->id(), 'Comment author successfully changed to a registered user.');
 
     $this->drupalLogout();
 
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
index 47efe82..1e443ac 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
@@ -68,7 +68,7 @@ function setUp() {
     // Change user language preference, this way interface language is always
     // French no matter what path prefix the URLs have.
     $edit = array('preferred_langcode' => 'fr');
-    $this->drupalPost("user/{$admin_user->uid}/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $admin_user->id() . "/edit", $edit, t('Save'));
 
     // Make comment body translatable.
     $field = field_info_field('comment_body');
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
index e121432..6d84a76 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
@@ -51,7 +51,7 @@ public function testCommentNewCommentsIndicator() {
       'nid' => $this->node->nid,
       'node_type' => $this->node->type,
       'pid' => 0,
-      'uid' => $this->loggedInUser->uid,
+      'uid' => $this->loggedInUser->id(),
       'status' => COMMENT_PUBLISHED,
       'subject' => $this->randomName(),
       'hostname' => '127.0.0.1',
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
index bf1cf6b..0b7cd20 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
@@ -52,7 +52,7 @@ function testCommentPreview() {
     $edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
     $image = current($this->drupalGetTestFiles('image'));
     $edit['files[user_picture_und_0]'] = drupal_realpath($image->uri);
-    $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $this->web_user->id() . '/edit', $edit, t('Save'));
 
     // As the web user, fill in the comment form and preview the comment.
     $edit = array();
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php
index 4578ade..06ebf86 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php
@@ -51,7 +51,7 @@ function testCommentNodeCommentStatistics() {
     $node = node_load($this->node->nid);
     $this->assertEqual($node->last_comment_timestamp, $this->node->created, 'The initial value of node last_comment_timestamp is the node created date.');
     $this->assertEqual($node->last_comment_name, NULL, 'The initial value of node last_comment_name is NULL.');
-    $this->assertEqual($node->last_comment_uid, $this->web_user->uid, 'The initial value of node last_comment_uid is the node uid.');
+    $this->assertEqual($node->last_comment_uid, $this->web_user->id(), 'The initial value of node last_comment_uid is the node uid.');
     $this->assertEqual($node->comment_count, 0, 'The initial value of node comment_count is zero.');
 
     // Post comment #1 as web_user2.
@@ -63,7 +63,7 @@ function testCommentNodeCommentStatistics() {
     // The node needs to be reloaded with a node_load_multiple cache reset.
     $node = node_load($this->node->nid, TRUE);
     $this->assertEqual($node->last_comment_name, NULL, 'The value of node last_comment_name is NULL.');
-    $this->assertEqual($node->last_comment_uid, $this->web_user2->uid, 'The value of node last_comment_uid is the comment #1 uid.');
+    $this->assertEqual($node->last_comment_uid, $this->web_user2->id(), 'The value of node last_comment_uid is the comment #1 uid.');
     $this->assertEqual($node->comment_count, 1, 'The value of node comment_count is 1.');
 
     // Prepare for anonymous comment submission (comment approval enabled).
@@ -86,7 +86,7 @@ function testCommentNodeCommentStatistics() {
     // The node needs to be reloaded with a node_load_multiple cache reset.
     $node = node_load($this->node->nid, TRUE);
     $this->assertEqual($node->last_comment_name, NULL, 'The value of node last_comment_name is still NULL.');
-    $this->assertEqual($node->last_comment_uid, $this->web_user2->uid, 'The value of node last_comment_uid is still the comment #1 uid.');
+    $this->assertEqual($node->last_comment_uid, $this->web_user2->id(), 'The value of node last_comment_uid is still the comment #1 uid.');
     $this->assertEqual($node->comment_count, 1, 'The value of node comment_count is still 1.');
 
     // Prepare for anonymous comment submission (no approval required).
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
index 22132c1..0332dd7 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
@@ -75,7 +75,7 @@ function setUp() {
     ));
 
     // Create a test node authored by the web user.
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->id()));
   }
 
   /**
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
index 3636f91..98860fc 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
@@ -36,7 +36,7 @@ function testCommentThreading() {
 
     // Create a node.
     $this->drupalLogin($this->web_user);
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->id()));
 
     // Post comment #1.
     $this->drupalLogin($this->web_user);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php
index 8234cb5..40a6f76 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php
@@ -29,7 +29,7 @@ public static function getInfo() {
 
   function testCommentUserUIDTest() {
     $view = views_get_view('test_comment_user_uid');
-    $this->executeView($view, array($this->account->uid));
+    $this->executeView($view, array($this->account->id()));
     $result_set = array(
       array(
         'nid' => $this->node_user_posted->nid,
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php
index c913883..2a14f1f 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php
@@ -44,7 +44,7 @@ function setUp() {
     $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->uid));
 
     $comment = array(
-      'uid' => $this->loggedInUser->uid,
+      'uid' => $this->loggedInUser->id(),
       'nid' => $this->node_user_commented->nid,
       'cid' => '',
       'pid' => '',
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php
index 9c8c880..e775687 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php
@@ -38,10 +38,10 @@ function testCommentUserUIDTest() {
       'id' => 'uid_touch',
       'table' => 'node_field_data',
       'field' => 'uid_touch',
-      'value' => array($this->loggedInUser->uid),
+      'value' => array($this->loggedInUser->id()),
     );
     $view->addItem('default', 'filter', 'node_field_data', 'uid_touch', $options);
-    $this->executeView($view, array($this->account->uid));
+    $this->executeView($view, array($this->account->id()));
     $result_set = array(
       array(
         'nid' => $this->node_user_posted->nid,
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index a2d2359..6412d32 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -126,12 +126,12 @@ function _contact_personal_tab_access($account) {
   global $user;
 
   // Anonymous users cannot have contact forms.
-  if (!$account->uid) {
+  if ($account->isAnonymous()) {
     return FALSE;
   }
 
   // Users may not contact themselves.
-  if ($user->uid == $account->uid) {
+  if ($user->id() == $account->id()) {
     return FALSE;
   }
 
@@ -269,7 +269,7 @@ function contact_mail($key, &$message, $params) {
     '!form-url' => url(current_path(), array('absolute' => TRUE, 'language' => $language)),
     '!sender-name' => user_format_name($sender),
   );
-  if (!empty($sender->uid)) {
+  if ($sender->isAuthenticated()) {
     $sender_uri = $sender->uri();
     $variables['!sender-url'] = url($sender_uri['path'], array('absolute' => TRUE, 'language' => $language) + $sender_uri['options']);
   }
@@ -297,7 +297,7 @@ function contact_mail($key, &$message, $params) {
     case 'user_copy':
       $variables += array(
         '!recipient-name' => user_format_name($params['recipient']),
-        '!recipient-edit-url' => url('user/' . $params['recipient']->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
+        '!recipient-edit-url' => url('user/' . $params['recipient']->id() . '/edit', array('absolute' => TRUE, 'language' => $language)),
       );
       $message['subject'] .= t('[!site-name] !subject', $variables, $options);
       $message['body'][] = t('Hello !recipient-name,', $variables, $options);
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index bf807a6..a4abbac 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -44,7 +44,7 @@ public function form(array $form, array &$form_state) {
       '#title' => t('Your e-mail address'),
       '#required' => TRUE,
     );
-    if (!$user->uid) {
+    if ($user->isAnonymous()) {
       $form['#attached']['library'][] = array('system', 'jquery.cookie');
       $form['#attributes']['class'][] = 'user-info-from-cookie';
     }
@@ -93,7 +93,7 @@ public function form(array $form, array &$form_state) {
       '#title' => t('Send yourself a copy.'),
       // Do not allow anonymous users to send themselves a copy, because it can
       // be abused to spam people.
-      '#access' => !empty($user->uid),
+      '#access' => $user->isAuthenticated(),
     );
     return $form;
   }
@@ -136,8 +136,8 @@ public function save(array $form, array &$form_state) {
     $language_interface = language(Language::TYPE_INTERFACE);
     $message = $this->entity;
 
-    $sender = clone user_load($user->uid);
-    if (!$user->uid) {
+    $sender = clone user_load($user->id());
+    if ($user->isAnonymous()) {
       // At this point, $sender contains drupal_anonymous_user(), so we need to
       // take over the submitted form values.
       $sender->name = $message->getSenderName();
@@ -164,7 +164,7 @@ public function save(array $form, array &$form_state) {
     elseif ($recipient = $message->getPersonalRecipient()) {
       // Send to the user in the user's preferred language.
       $to = $recipient->mail->value;
-      $recipient_langcode = user_preferred_langcode($recipient);
+      $recipient_langcode = $recipient->getPreferredLangcode();
       $params['recipient'] = $recipient->getBCEntity();
     }
     else {
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
index e027b63..0f6c72b 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
@@ -92,22 +92,22 @@ function testSendPersonalContactMessage() {
   function testPersonalContactAccess() {
     // Test allowed access to admin user's contact form.
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('user/' . $this->admin_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Test denied access to admin user's own contact form.
     $this->drupalLogout();
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('user/' . $this->admin_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
     $this->assertResponse(403);
 
     // Test allowed access to user with contact form enabled.
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Test denied access to the user's own contact form.
-    $this->drupalGet('user/' . $this->web_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->web_user->id() . '/contact');
     $this->assertResponse(403);
 
     // Test always denied access to the anonymous user contact form.
@@ -117,18 +117,18 @@ function testPersonalContactAccess() {
     // Test that anonymous users can access the contact form.
     $this->drupalLogout();
     user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Test that anonymous users can access admin user's contact form.
-    $this->drupalGet('user/' . $this->admin_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Revoke the personal contact permission for the anonymous user.
     user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access user contact forms'));
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(403);
-    $this->drupalGet('user/' . $this->admin_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/contact');
     $this->assertResponse(403);
 
     // Disable the personal contact form.
@@ -144,12 +144,12 @@ function testPersonalContactAccess() {
 
     // Test denied access to a user with contact form disabled.
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(403);
 
     // Test allowed access for admin user to a user with contact form disabled.
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Re-create our contacted user as a blocked user.
@@ -158,12 +158,12 @@ function testPersonalContactAccess() {
     $this->contact_user->save();
 
     // Test that blocked users can still be contacted by admin.
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(200);
 
     // Test that blocked users cannot be contacted by non-admins.
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('user/' . $this->contact_user->uid . '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id() . '/contact');
     $this->assertResponse(403);
   }
 
@@ -188,7 +188,7 @@ function testPersonalContactFlood() {
     }
 
     // Submit contact form one over limit.
-    $this->drupalGet('user/' . $this->contact_user->uid. '/contact');
+    $this->drupalGet('user/' . $this->contact_user->id(). '/contact');
     $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => format_interval(config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.');
 
     // Test that the admin user can still access the contact form even though
@@ -211,7 +211,7 @@ protected function submitPersonalContact($account, array $message = array()) {
       'subject' => $this->randomName(16),
       'message' => $this->randomName(64),
     );
-    $this->drupalPost('user/' . $account->uid . '/contact', $message, t('Send message'));
+    $this->drupalPost('user/' . $account->id() . '/contact', $message, t('Send message'));
     return $message;
   }
 }
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index e09e1cf..a6988cf 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -730,7 +730,7 @@ function content_translation_entity_insert(EntityInterface $entity) {
 
     $translation += array(
       'source' => '',
-      'uid' => $GLOBALS['user']->uid,
+      'uid' => $GLOBALS['user']->id(),
       'outdated' => FALSE,
       'status' => TRUE,
       'created' => REQUEST_TIME,
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php
index 2386f1f..6948642 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php
@@ -410,7 +410,7 @@ public function entityFormEntityBuild($entity_type, EntityInterface $entity, arr
 
     // @todo Use the entity setter when all entities support multilingual
     // properties.
-    $translation['uid'] = !empty($values['name']) && ($account = user_load_by_name($values['name'])) ? $account->uid : 0;
+    $translation['uid'] = !empty($values['name']) && ($account = user_load_by_name($values['name'])) ? $account->id() : 0;
     $translation['status'] = !empty($values['status']);
     $translation['created'] = !empty($values['created']) ? strtotime($values['created']) : REQUEST_TIME;
     $translation['changed'] = REQUEST_TIME;
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php
index c9bf33d..54d234e 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php
@@ -107,7 +107,7 @@ function testImageFieldSync() {
       // identifier.
       $field_values = array(
         'uri' => $this->files[$index]->uri,
-        'uid' => $GLOBALS['user']->uid,
+        'uid' => $GLOBALS['user']->id(),
         'status' => FILE_STATUS_PERMANENT,
       );
       $file = entity_create('file', $field_values);
diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
index 94006ea..e2b5011 100644
--- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
+++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php
@@ -165,7 +165,7 @@ protected function assertAuthoringInfo() {
     foreach ($this->langcodes as $index => $langcode) {
       $user = $this->drupalCreateUser();
       $values[$langcode] = array(
-        'uid' => $user->uid,
+        'uid' => $user->id(),
         'created' => REQUEST_TIME - mt_rand(0, 1000),
       );
       $edit = array(
diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc
index d3cc328..d67712a 100644
--- a/core/modules/dblog/dblog.admin.inc
+++ b/core/modules/dblog/dblog.admin.inc
@@ -99,7 +99,7 @@ function dblog_event($id) {
     }
     $username = array(
       '#theme' => 'username',
-      '#account' => $dblog,
+      '#account' => user_load($dblog->uid),
     );
     $rows = array(
       array(
diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
index f416c41..3119a1b 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
@@ -124,7 +124,6 @@ public function overview() {
     $query = $this->database->select('watchdog', 'w')
       ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
       ->extend('Drupal\Core\Database\Query\TableSortExtender');
-    $query->leftJoin('users', 'u', 'w.uid = u.uid');
     $query->fields('w', array(
       'wid',
       'uid',
@@ -134,8 +133,7 @@ public function overview() {
       'message',
       'variables',
       'link',
-      ));
-    $query->addField('u', 'name');
+    ));
 
     if (!empty($filter['where'])) {
       $query->where($filter['where'], $filter['args']);
@@ -164,7 +162,7 @@ public function overview() {
       }
       $username = array(
         '#theme' => 'username',
-        '#account' => $dblog,
+        '#account' => user_load($dblog->uid),
       );
       $rows[] = array(
         'data' => array(
diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
index e619fff..5e3f663 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
@@ -136,7 +136,7 @@ private function generateLogEntries($count, $type = 'custom', $severity = WATCHD
       'severity'    => $severity,
       'link'        => NULL,
       'user'        => $this->big_user,
-      'uid'         => isset($this->big_user->uid) ? $this->big_user->uid : 0,
+      'uid'         => $this->big_user->id(),
       'request_uri' => $base_root . request_uri(),
       'referer'     => $_SERVER['HTTP_REFERER'],
       'ip'          => '127.0.0.1',
@@ -238,7 +238,7 @@ private function doUser() {
     // Logout user.
     $this->drupalLogout();
     // Fetch the row IDs in watchdog that relate to the user.
-    $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->uid));
+    $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->id()));
     foreach ($result as $row) {
       $ids[] = $row->wid;
     }
@@ -249,7 +249,7 @@ private function doUser() {
     $this->drupalLogin($this->big_user);
     // Delete the user created at the start of this test.
     // We need to POST here to invoke batch_process() in the internal browser.
-    $this->drupalPost('user/' . $user->uid . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
+    $this->drupalPost('user/' . $user->id() . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
 
     // View the database log report.
     $this->drupalGet('admin/reports/dblog');
@@ -423,7 +423,7 @@ protected function testDBLogAddAndClear() {
       'severity'    => WATCHDOG_NOTICE,
       'link'        => NULL,
       'user'        => $this->big_user,
-      'uid'         => isset($this->big_user->uid) ? $this->big_user->uid : 0,
+      'uid'         => $this->big_user->id(),
       'request_uri' => $base_root . request_uri(),
       'referer'     => $_SERVER['HTTP_REFERER'],
       'ip'          => '127.0.0.1',
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php
index 909b780..9798a53 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php
@@ -94,7 +94,7 @@ public function formElement(array $items, $delta, array $element, $langcode, arr
       '#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->uid,
+      '#autocreate_uid' => isset($entity->uid) ? $entity->uid : $user->id(),
     );
 
     return array('target_id' => $element);
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
index 9a611d4..f064b77 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
@@ -272,8 +272,8 @@ public function testUserHandler() {
         ),
         'result' => array(
           'user' => array(
-            $users['admin']->uid => $user_labels['admin'],
-            $users['non_admin']->uid => $user_labels['non_admin'],
+            $users['admin']->id() => $user_labels['admin'],
+            $users['non_admin']->id() => $user_labels['non_admin'],
           ),
         ),
       ),
@@ -284,7 +284,7 @@ public function testUserHandler() {
         ),
         'result' => array(
           'user' => array(
-            $users['non_admin']->uid => $user_labels['non_admin'],
+            $users['non_admin']->id() => $user_labels['non_admin'],
           ),
         ),
       ),
@@ -311,10 +311,10 @@ public function testUserHandler() {
         ),
         'result' => array(
           'user' => array(
-            $users['anonymous']->uid => $user_labels['anonymous'],
-            $users['admin']->uid => $user_labels['admin'],
-            $users['non_admin']->uid => $user_labels['non_admin'],
-            $users['blocked']->uid => $user_labels['blocked'],
+            $users['anonymous']->id() => $user_labels['anonymous'],
+            $users['admin']->id() => $user_labels['admin'],
+            $users['non_admin']->id() => $user_labels['non_admin'],
+            $users['blocked']->id() => $user_labels['blocked'],
           ),
         ),
       ),
@@ -324,7 +324,7 @@ public function testUserHandler() {
         ),
         'result' => array(
           'user' => array(
-            $users['blocked']->uid => $user_labels['blocked'],
+            $users['blocked']->id() => $user_labels['blocked'],
           ),
         ),
       ),
@@ -335,7 +335,7 @@ public function testUserHandler() {
         ),
         'result' => array(
           'user' => array(
-            $users['anonymous']->uid => $user_labels['anonymous'],
+            $users['anonymous']->id() => $user_labels['anonymous'],
           ),
         ),
       ),
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index bcdb460..0d66adb 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -400,7 +400,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
   }
 
   // Save a query by only calling spaceUsed() when a limit is provided.
-  if ($user_limit && (Drupal::entityManager()->getStorageController('file')->spaceUsed($user->uid) + $file->getSize()) > $user_limit) {
+  if ($user_limit && (Drupal::entityManager()->getStorageController('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) {
     $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit)));
   }
 
@@ -525,7 +525,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
     // Create a file entity.
     $file = entity_create('file', array(
       'uri' => $uri,
-      'uid' => $user->uid,
+      'uid' => $user->id(),
       'status' => FILE_STATUS_PERMANENT,
     ));
     // If we are replacing an existing file re-use its database record.
@@ -635,7 +635,7 @@ function file_file_download($uri, $field_type = 'file') {
   // temporary files where the host entity has not yet been saved (for example,
   // an image preview on a node/add form) in which case, allow download by the
   // file's owner.
-  if (empty($references) && ($file->isPermanent() || $file->getOwner()->id() != $user->uid)) {
+  if (empty($references) && ($file->isPermanent() || $file->getOwner()->id() != $user->id())) {
     return;
   }
 
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
index 84e23c3..bfe2414 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
@@ -99,7 +99,7 @@ function testRevisions() {
     $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'] = $node_file_r3->id();
     $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['display'] = 1;
     $user->save();
-    $this->drupalGet('user/' . $user->uid . '/edit');
+    $this->drupalGet('user/' . $user->id() . '/edit');
 
     // Delete the third revision and check that the file is not deleted yet.
     $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete'));
@@ -108,7 +108,7 @@ function testRevisions() {
     $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting third revision, since it is being used by the user.');
 
     // Delete the user and check that the file is also deleted.
-    user_delete($user->uid);
+    $user->delete();
     // TODO: This seems like a bug in File API. Clearing the stat cache should
     // not be necessary here. The file really is deleted, but stream wrappers
     // doesn't seem to think so unless we clear the PHP file stat() cache.
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index a58d7a2..290b3da 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -290,16 +290,16 @@ function filter_formats($account = NULL) {
   }
 
   // Build a list of user-specific formats.
-  if (isset($account) && !isset($formats['user'][$account->uid])) {
-    $formats['user'][$account->uid] = array();
+  if (isset($account) && !isset($formats['user'][$account->id()])) {
+    $formats['user'][$account->id()] = array();
     foreach ($formats['all'] as $format) {
       if (filter_access($format, $account)) {
-        $formats['user'][$account->uid][$format->format] = $format;
+        $formats['user'][$account->id()][$format->format] = $format;
       }
     }
   }
 
-  return isset($account) ? $formats['user'][$account->uid] : $formats['all'];
+  return isset($account) ? $formats['user'][$account->id()] : $formats['all'];
 }
 
 /**
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 73806a8..18dd4e9 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -199,7 +199,7 @@ function forum_menu_local_tasks(&$data, $router_item, $root_path) {
       }
       if (empty($links)) {
         // Authenticated user does not have access to create new topics.
-        if ($user->uid) {
+        if ($user->isAuthenticated()) {
           $links['disallowed'] = array(
             '#theme' => 'menu_local_action',
             '#link' => array(
@@ -912,7 +912,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
   $topics = array();
   $first_new_found = FALSE;
   foreach ($result as $topic) {
-    if ($user->uid) {
+    if ($user->isAuthenticated()) {
       // A forum is new if the topic is new, or if there are new comments since
       // the user's last visit.
       if ($topic->forum_tid != $tid) {
@@ -1060,8 +1060,8 @@ function template_preprocess_forum_list(&$variables) {
     $variables['forums'][$id]->old_topics = $forum->num_topics;
     $variables['forums'][$id]->icon_class = 'default';
     $variables['forums'][$id]->icon_title = t('No new posts');
-    if ($user->uid) {
-      $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->id(), $user->uid);
+    if ($user->isAuthenticated()) {
+      $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->id(), $user->id());
       if ($variables['forums'][$id]->new_topics) {
         $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new post<span class="visually-hidden"> in forum %title</span>', '@count new posts<span class="visually-hidden"> in forum %title</span>', array('%title' => $variables['forums'][$id]->label()));
         $variables['forums'][$id]->new_url = url('forum/' . $forum->id(), array('fragment' => 'new'));
@@ -1211,7 +1211,7 @@ function template_preprocess_forum_icon(&$variables) {
  *   - topic: The topic object.
  */
 function template_preprocess_forum_submitted(&$variables) {
-  $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => $variables['topic'])) : '';
+  $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => user_load($variables['topic']->uid))) : '';
   $variables['time'] = isset($variables['topic']->created) ? format_interval(REQUEST_TIME - $variables['topic']->created) : '';
 }
 
@@ -1230,7 +1230,7 @@ function _forum_user_last_visit($nid) {
   $history = &drupal_static(__FUNCTION__, array());
 
   if (empty($history)) {
-    $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid', array(':uid' => $user->uid));
+    $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = :uid', array(':uid' => $user->id()));
     foreach ($result as $t) {
       $history[$t->nid] = $t->timestamp > HISTORY_READ_LIMIT ? $t->timestamp : HISTORY_READ_LIMIT;
     }
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
index 63f1da3..149441f 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
@@ -190,7 +190,7 @@ function testForum() {
     $this->assertEqual($topics, '6', 'Number of topics found.');
 
     // Verify the number of unread topics.
-    $unread_topics = _forum_topics_unread($this->forum['tid'], $this->edit_any_topics_user->uid);
+    $unread_topics = _forum_topics_unread($this->forum['tid'], $this->edit_any_topics_user->id());
     $unread_topics = format_plural($unread_topics, '1 new post', '@count new posts');
     $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg);
     $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.');
diff --git a/core/modules/history/history.module b/core/modules/history/history.module
index 84abade..2a182c0 100644
--- a/core/modules/history/history.module
+++ b/core/modules/history/history.module
@@ -34,7 +34,7 @@ function history_read($nid) {
   $history = &drupal_static(__FUNCTION__, array());
 
   if (!isset($history[$nid])) {
-    $history[$nid] = db_query("SELECT timestamp FROM {history} WHERE uid = :uid AND nid = :nid", array(':uid' => $user->uid, ':nid' => $nid))->fetchObject();
+    $history[$nid] = db_query("SELECT timestamp FROM {history} WHERE uid = :uid AND nid = :nid", array(':uid' => $user->id(), ':nid' => $nid))->fetchObject();
   }
 
   return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
@@ -56,10 +56,10 @@ function history_write($nid, $account = NULL) {
     $account = $user;
   }
 
-  if ($account->uid) {
+  if ($account->isAuthenticated()) {
     db_merge('history')
       ->key(array(
-        'uid' => $account->uid,
+        'uid' => $account->id(),
         'nid' => $nid,
       ))
       ->fields(array('timestamp' => REQUEST_TIME))
@@ -92,7 +92,7 @@ function history_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
       db_delete('history')
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute();
       break;
   }
@@ -103,6 +103,6 @@ function history_user_cancel($edit, $account, $method) {
  */
 function history_user_delete($account) {
   db_delete('history')
-    ->condition('uid', $account->uid)
+    ->condition('uid', $account->id())
     ->execute();
 }
diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
index 5d5a697..d2fcecf 100644
--- a/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
+++ b/core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php
@@ -31,7 +31,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
     parent::init($view, $display, $options);
 
     global $user;
-    if ($user->uid) {
+    if ($user->isAuthenticated()) {
       $this->additional_fields['created'] = array('table' => 'node_field_data', 'field' => 'created');
       $this->additional_fields['changed'] = array('table' => 'node_field_data', 'field' => 'changed');
       if (module_exists('comment') && !empty($this->options['comments'])) {
@@ -63,7 +63,7 @@ public function buildOptionsForm(&$form, &$form_state) {
   public function query() {
     // Only add ourselves to the query if logged in.
     global $user;
-    if (!$user->uid) {
+    if ($user->isAnonymous()) {
       return;
     }
     parent::query();
@@ -75,7 +75,7 @@ function render($values) {
     // we already have that info.
     $mark = MARK_READ;
     global $user;
-    if ($user->uid) {
+    if ($user->isAuthenticated()) {
       $last_read = $this->getValue($values);
       $changed = $this->getValue($values, 'changed');
 
diff --git a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php
index 8569329..beae395 100644
--- a/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php
+++ b/core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php
@@ -54,8 +54,8 @@ protected function valueForm(&$form, &$form_state) {
 
   public function query() {
     global $user;
-    // This can only work if we're logged in.
-    if (!$user || !$user->uid) {
+    // This can only work if we're authenticated in.
+    if (!$user->isAuthenticated()) {
       return;
     }
 
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index b26105f..15093fd 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -463,8 +463,9 @@ function language_get_default_langcode($entity_type, $bundle) {
 
     case 'authors_default':
       global $user;
-      if (!empty($user->preferred_langcode)) {
-        $default_value = $user->preferred_langcode;
+      $language_code = $user->getPreferredLangcode();
+      if (!empty($language_code)) {
+        $default_value = $language_code;
       }
       else {
         $default_value = $language_interface->id;
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index 78b9d27..9e145bb 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -191,8 +191,12 @@ function language_from_user($languages) {
   // User preference (only for authenticated users).
   global $user;
 
-  if ($user->uid && !empty($user->preferred_langcode) && isset($languages[$user->preferred_langcode])) {
-    return $user->preferred_langcode;
+  if ($user->id()) {
+    $langcode = $user->getPreferredLangcode();
+    $default_langcode = language_default()->id;
+    if (!empty($langcode) && $langcode != $default_langcode && isset($languages[$langcode])) {
+      return $langcode;
+    }
   }
 
   // No language preference from the user.
@@ -216,9 +220,13 @@ function language_from_user_admin(array $languages, Request $request = NULL) {
   // User preference (only for authenticated users).
   global $user;
 
-  $request_path = $request ? urldecode(trim($request->getPathInfo(), '/')) : _current_path();
-  if ($user->uid && !empty($user->preferred_admin_langcode) && isset($languages[$user->preferred_admin_langcode]) && path_is_admin($request_path)) {
-    return $user->preferred_admin_langcode;
+  if ($user->id()) {
+    $request_path = $request ? urldecode(trim($request->getPathInfo(), '/')) : _current_path();
+    $langcode = $user->getPreferredAdminLangcode();
+    $default_langcode = language_default()->id;
+    if (!empty($langcode) && $langcode != $default_langcode && isset($languages[$langcode]) && path_is_admin($request_path)) {
+      return $langcode;
+    }
   }
 
   // No language preference from the user or not on an admin path.
@@ -241,7 +249,7 @@ function language_from_session($languages) {
   // an authenticated user.
   if (isset($_GET[$param]) && isset($languages[$langcode = $_GET[$param]])) {
     global $user;
-    if ($user->uid) {
+    if ($user->id()) {
       $_SESSION[$param] = $langcode;
     }
     return $langcode;
@@ -479,7 +487,7 @@ function language_url_rewrite_session(&$path, &$options) {
   // request processing.
   if (!isset($query_rewrite)) {
     global $user;
-    if (!$user->uid) {
+    if (!$user->id()) {
       $languages = language_list();
       $query_param = check_plain(config('language.negotiation')->get('session.parameter'));
       $query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
index 7b1219b..cb9be73 100644
--- a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
+++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
@@ -70,7 +70,7 @@ public function configContext(ConfigEvent $event) {
       $context->set('locale.language', $language);
     }
     elseif ($account = $context->get('user.account')) {
-      $context->set('locale.language', language_load(user_preferred_langcode($account)));
+      $context->set('locale.language', language_load($account->getPreferredLangcode()));
     }
     elseif ($language = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)) {
       $context->set('locale.language', $language);
diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php
index 7a43181..8395fcb 100644
--- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php
+++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php
@@ -96,7 +96,7 @@ public function getConfirmText() {
    * {@inheritdoc}
    */
   public function buildForm(array $form, array &$form_state) {
-    $this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get($GLOBALS['user']->uid);
+    $this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get($GLOBALS['user']->id());
     if (empty($this->nodes)) {
       return new RedirectResponse(url($this->getCancelPath(), array('absolute' => TRUE)));
     }
@@ -116,7 +116,7 @@ public function buildForm(array $form, array &$form_state) {
   public function submitForm(array &$form, array &$form_state) {
     if ($form_state['values']['confirm'] && !empty($this->nodes)) {
       $this->storageController->delete($this->nodes);
-      $this->tempStoreFactory->get('node_multiple_delete_confirm')->delete($GLOBALS['user']->uid);
+      $this->tempStoreFactory->get('node_multiple_delete_confirm')->delete($GLOBALS['user']->id());
       $count = count($this->nodes);
       watchdog('content', 'Deleted @count posts.', array('@count' => $count));
       drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index e55e056..814d937 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -47,7 +47,7 @@ protected function prepareEntity() {
         }
       }
       global $user;
-      $node->uid = $user->uid;
+      $node->uid = $user->id();
       $node->created = REQUEST_TIME;
     }
     else {
diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php
index f4a5eff..6376f57 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php
@@ -61,7 +61,7 @@ public static function create(ContainerInterface $container, array $configuratio
    * {@inheritdoc}
    */
   public function executeMultiple(array $entities) {
-    $this->tempStore->set($GLOBALS['user']->uid, $entities);
+    $this->tempStore->set($GLOBALS['user']->id(), $entities);
   }
 
   /**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
index adee17d..5107337 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
@@ -92,7 +92,7 @@ function testNodeAccessBasic() {
           $private_nodes[] = $nid;
         }
         $titles[$nid] = $edit['title'];
-        $this->nodesByUser[$this->webUser->uid][$nid] = $is_private;
+        $this->nodesByUser[$this->webUser->id()][$nid] = $is_private;
       }
     }
     $this->publicTid = db_query('SELECT tid FROM {taxonomy_term_data} WHERE name = :name', array(':name' => 'public'))->fetchField();
@@ -106,7 +106,7 @@ function testNodeAccessBasic() {
         foreach ($data as $nid => $is_private) {
           $this->drupalGet('node/' . $nid);
           if ($is_private) {
-            $should_be_visible = $uid == $this->webUser->uid;
+            $should_be_visible = $uid == $this->webUser->id();
           }
           else {
             $should_be_visible = TRUE;
@@ -115,7 +115,7 @@ function testNodeAccessBasic() {
             '%private' => $is_private ? 'private' : 'public',
             '%uid' => $uid,
             '%visible' => $should_be_visible ? 'visible' : 'not visible',
-            '%current_uid' => $this->webUser->uid,
+            '%current_uid' => $this->webUser->id(),
           )));
         }
       }
@@ -165,13 +165,13 @@ protected function assertTaxonomyPage($is_admin) {
           // Non-administrators can only see their own nodes on the private
           // term page.
           if (!$is_admin && $tid_is_private) {
-            $should_be_visible = $should_be_visible && $uid == $this->webUser->uid;
+            $should_be_visible = $should_be_visible && $uid == $this->webUser->id();
           }
           $this->assertIdentical(isset($this->nids_visible[$nid]), $should_be_visible, strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', array(
             '%private' => $is_private ? 'private' : 'public',
             '%uid' => $uid,
             '%visible' => isset($this->nids_visible[$nid]) ? 'visible' : 'not visible',
-            '%current_uid' => $this->webUser->uid,
+            '%current_uid' => $this->webUser->id(),
             '%tid_is_private' => $tid_is_private ? 'private' : 'public',
           )));
         }
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessTest.php
index 4a5e0f8..a6762b0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessTest.php
@@ -47,7 +47,7 @@ function testNodeAccess() {
 
     // User cannot 'view own unpublished content'.
     $web_user3 = $this->drupalCreateUser(array('access content'));
-    $node3 = $this->drupalCreateNode(array('status' => 0, 'uid' => $web_user3->uid));
+    $node3 = $this->drupalCreateNode(array('status' => 0, 'uid' => $web_user3->id()));
     $this->assertNodeAccess(array('view' => FALSE), $node3, $web_user3);
 
     // User cannot create content without permission.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
index 8d95c06..b308072 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
@@ -68,7 +68,7 @@ public function testRecentNodeBlock() {
     $this->assertText(t('No content available.'), 'Block with "No content available." found.');
 
     // Add some test nodes.
-    $default_settings = array('uid' => $this->webUser->uid, 'type' => 'article');
+    $default_settings = array('uid' => $this->webUser->id(), 'type' => 'article');
     $node1 = $this->drupalCreateNode($default_settings);
     $node2 = $this->drupalCreateNode($default_settings);
     $node3 = $this->drupalCreateNode($default_settings);
@@ -136,7 +136,7 @@ public function testRecentNodeBlock() {
     $this->assertTrue(isset($visibility['node_type']['types']['article']), 'Visibility settings were saved to configuration');
 
     // Create a page node.
-    $node5 = $this->drupalCreateNode(array('uid' => $this->adminUser->uid, 'type' => 'page'));
+    $node5 = $this->drupalCreateNode(array('uid' => $this->adminUser->id(), 'type' => 'page'));
 
     // Verify visibility rules.
     $this->drupalGet('');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index 55719bb..90592b0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
@@ -64,7 +64,7 @@ function testNodeCreation() {
   function testFailedPageCreation() {
     // Create a node.
     $edit = array(
-      'uid'      => $this->loggedInUser->uid,
+      'uid'      => $this->loggedInUser->id(),
       'name'     => $this->loggedInUser->name,
       'type'     => 'page',
       'langcode' => Language::LANGCODE_NOT_SPECIFIED,
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
index 2caeca9..4d62136 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
@@ -169,7 +169,7 @@ function testNodeQueryAlterOverride() {
     // $account instead of the global $user, we will log in as
     // noAccessUser2.
     $this->drupalLogin($this->noAccessUser2);
-    \Drupal::state()->set('node_access_test.no_access_uid', $this->noAccessUser->uid);
+    \Drupal::state()->set('node_access_test.no_access_uid', $this->noAccessUser->id());
     drupal_static_reset('node_access_view_all_nodes');
     try {
       $query = db_select('node', 'mytab')
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
index 6157fb0..0a1c210 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
@@ -52,7 +52,7 @@ function testImport() {
     $node = array(
       'title' => $title,
       'body' => array(array('value' => $this->randomName(32))),
-      'uid' => $this->web_user->uid,
+      'uid' => $this->web_user->id(),
       'type' => 'article',
       'nid' => $test_nid,
     );
@@ -60,7 +60,7 @@ function testImport() {
     $node->enforceIsNew();
 
     // Verify that node_submit did not overwrite the user ID.
-    $this->assertEqual($node->uid, $this->web_user->uid, 'Function node_submit() preserves user ID');
+    $this->assertEqual($node->uid, $this->web_user->id(), 'Function node_submit() preserves user ID');
 
     $node->save();
     // Test the import.
@@ -77,7 +77,7 @@ function testImport() {
   function testTimestamps() {
     // Use the default timestamps.
     $edit = array(
-      'uid' => $this->web_user->uid,
+      'uid' => $this->web_user->id(),
       'type' => 'article',
       'title' => $this->randomName(8),
     );
@@ -105,7 +105,7 @@ function testTimestamps() {
 
     // Programmatically set the timestamps on the node.
     $edit = array(
-      'uid' => $this->web_user->uid,
+      'uid' => $this->web_user->id(),
       'type' => 'article',
       'title' => $this->randomName(8),
       'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
@@ -136,7 +136,7 @@ function testTimestamps() {
   function testDeterminingChanges() {
     // Initial creation.
     $node = entity_create('node', array(
-      'uid' => $this->web_user->uid,
+      'uid' => $this->web_user->id(),
       'type' => 'article',
       'title' => 'test_changes',
     ));
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
index 9037751..8bb425d 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -36,7 +36,7 @@ function testNodeTokenReplacement() {
     $account = $this->drupalCreateUser();
     $settings = array(
       'type' => 'article',
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'title' => '<blink>Blinking Text</blink>',
       'body' => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16))),
     );
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
index bea3245..473947b 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
@@ -120,7 +120,7 @@ protected function assertAuthoringInfo() {
     foreach ($this->langcodes as $index => $langcode) {
       $user = $this->drupalCreateUser();
       $values[$langcode] = array(
-        'uid' => $user->uid,
+        'uid' => $user->id(),
         'created' => REQUEST_TIME - mt_rand(0, 1000),
       );
       $edit = array(
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
index c37a227..2407dfb 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
@@ -114,7 +114,7 @@ function testPageAuthoredBy() {
 
     // Check that the node was authored by the currently logged in user.
     $node = $this->drupalGetNodeByTitle($edit['title']);
-    $this->assertIdentical($node->uid, $this->admin_user->uid, 'Node authored by admin user.');
+    $this->assertIdentical($node->uid, $this->admin_user->id(), 'Node authored by admin user.');
 
     // Try to change the 'authored by' field to an invalid user name.
     $edit = array(
@@ -135,7 +135,7 @@ function testPageAuthoredBy() {
     $edit['name'] = $this->web_user->name;
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
     $node = node_load($node->nid, TRUE);
-    $this->assertIdentical($node->uid, $this->web_user->uid, 'Node authored by normal user.');
+    $this->assertIdentical($node->uid, $this->web_user->id(), 'Node authored by normal user.');
 
     // Check that normal users cannot change the authored by information.
     $this->drupalLogin($this->web_user);
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 1d80c2e..eeec22b 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -229,7 +229,7 @@ function node_admin_nodes() {
     // If the user is able to view their own unpublished nodes, allow them
     // to see these in addition to published nodes. Check that they actually
     // have some unpublished nodes to view before adding the condition.
-    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) {
+    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->id(), ':status' => 0))->fetchCol()) {
       $query->condition(db_or()
         ->condition('n.status', 1)
         ->condition('n.nid', $own_unpublished, 'IN')
@@ -276,7 +276,7 @@ function node_admin_nodes() {
     );
     $form['nodes'][$node->nid]['author'] = array(
       '#theme' => 'username',
-      '#account' => $node,
+      '#account' => user_load($node->uid),
     );
     $form['nodes'][$node->nid]['status'] = array(
       '#markup' => $node->status ? t('published') : t('not published'),
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 51abca3..97f9a89 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -187,7 +187,7 @@ function hook_node_grants($account, $op) {
   if (user_access('access private content', $account)) {
     $grants['example'] = array(1);
   }
-  $grants['example_owner'] = array($account->uid);
+  $grants['example_owner'] = array($account->id());
   return $grants;
 }
 
@@ -577,13 +577,13 @@ function hook_node_access($node, $op, $account, $langcode) {
     }
 
     if ($op == 'update') {
-      if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
+      if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->id() == $node->uid))) {
         return NODE_ACCESS_ALLOW;
       }
     }
 
     if ($op == 'delete') {
-      if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
+      if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->id() == $node->uid))) {
         return NODE_ACCESS_ALLOW;
       }
     }
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index b9c5bd3..aca8668 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -281,7 +281,7 @@ function node_mark($nid, $timestamp) {
   global $user;
   $cache = &drupal_static(__FUNCTION__, array());
 
-  if (!$user->uid || !module_exists('history')) {
+  if ($user->isAnonymous() || !module_exists('history')) {
     return MARK_READ;
   }
   if (!isset($cache[$nid])) {
@@ -740,7 +740,7 @@ function template_preprocess_node(&$variables) {
   //   http://drupal.org/node/1941286.
   $username = array(
     '#theme' => 'username',
-    '#account' => $node,
+    '#account' => user_load($node->uid),
     '#link_options' => array('attributes' => array('rel' => 'author')),
   );
   $variables['name'] = drupal_render($username);
@@ -998,7 +998,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
     $uri = $node->uri();
     $username = array(
       '#theme' => 'username',
-      '#account' => $node,
+      '#account' => user_load($node->uid),
     );
     $results[] = array(
       'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))),
@@ -1062,7 +1062,7 @@ function node_user_cancel($edit, $account, $method) {
       $nodes = db_select('node_field_data', 'n')
         ->distinct()
         ->fields('n', array('nid'))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute()
         ->fetchCol();
       node_mass_update($nodes, array('status' => 0), NULL, TRUE);
@@ -1074,14 +1074,14 @@ function node_user_cancel($edit, $account, $method) {
       $nodes = db_select('node_field_data', 'n')
         ->distinct()
         ->fields('n', array('nid'))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute()
         ->fetchCol();
       node_mass_update($nodes, array('uid' => 0), NULL, TRUE);
       // Anonymize old revisions.
       db_update('node_field_revision')
         ->fields(array('uid' => 0))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute();
       break;
   }
@@ -1096,12 +1096,12 @@ function node_user_predelete($account) {
   $nodes = db_select('node_field_data', 'n')
     ->distinct()
     ->fields('n', array('nid'))
-    ->condition('uid', $account->uid)
+    ->condition('uid', $account->id())
     ->execute()
     ->fetchCol();
   entity_delete_multiple('node', $nodes);
   // Delete old revisions.
-  $revisions = db_query('SELECT DISTINCT vid FROM {node_field_revision} WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
+  $revisions = db_query('SELECT DISTINCT vid FROM {node_field_revision} WHERE uid = :uid', array(':uid' => $account->id()))->fetchCol();
   foreach ($revisions as $revision) {
     node_revision_delete($revision);
   }
@@ -1472,7 +1472,7 @@ function node_get_recent($number = 10) {
     // If the user is able to view their own unpublished nodes, allow them
     // to see these in addition to published nodes. Check that they actually
     // have some unpublished nodes to view before adding the condition.
-    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
+    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->id(), ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
       $query->condition(db_or()
         ->condition('n.status', NODE_PUBLISHED)
         ->condition('n.nid', $own_unpublished, 'IN')
@@ -2182,7 +2182,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
   // Make sure that if an account is passed, that it is a fully loaded user
   // object.
   if ($account && !($account instanceof UserInterface)) {
-    $account = user_load($account->uid);
+    $account = user_load($account->id());
   }
 
   return entity_access_controller('node')->access($node, $op, $langcode, $account);
@@ -2201,13 +2201,13 @@ function node_node_access($node, $op, $account) {
     }
 
     if ($op == 'update') {
-      if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->getAuthorId()))) {
+      if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->id() == $node->getAuthorId()))) {
         return NODE_ACCESS_ALLOW;
       }
     }
 
     if ($op == 'delete') {
-      if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->getAuthorId()))) {
+      if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->id() == $node->getAuthorId()))) {
         return NODE_ACCESS_ALLOW;
       }
     }
@@ -2346,15 +2346,15 @@ function node_access_view_all_nodes($account = NULL) {
     $account = $user;
   }
 
-  // Statically cache results in an array keyed by $account->uid.
+  // Statically cache results in an array keyed by $account->id().
   $access = &drupal_static(__FUNCTION__);
-  if (isset($access[$account->uid])) {
-    return $access[$account->uid];
+  if (isset($access[$account->id()])) {
+    return $access[$account->id()];
   }
 
   // If no modules implement the node access system, access is always TRUE.
   if (!module_implements('node_grants')) {
-    $access[$account->uid] = TRUE;
+    $access[$account->id()] = TRUE;
   }
   else {
     $query = db_select('node_access');
@@ -2375,12 +2375,12 @@ function node_access_view_all_nodes($account = NULL) {
     if (count($grants) > 0 ) {
       $query->condition($grants);
     }
-    $access[$account->uid] = $query
+    $access[$account->id()] = $query
       ->execute()
       ->fetchField();
   }
 
-  return $access[$account->uid];
+  return $access[$account->id()];
 }
 
 
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index af8e1e7..0532aa2 100644
--- a/core/modules/node/node.pages.inc
+++ b/core/modules/node/node.pages.inc
@@ -87,7 +87,7 @@ function node_add($node_type) {
   $type = $node_type->type;
   $langcode = module_invoke('language', 'get_default_langcode', 'node', $type);
   $node = entity_create('node', array(
-    'uid' => $user->uid,
+    'uid' => $user->id(),
     'name' => (isset($user->name) ? $user->name : ''),
     'type' => $type,
     'langcode' => $langcode ? $langcode : language_default()->id,
@@ -114,7 +114,7 @@ function node_preview(EntityInterface $node) {
       // The use of isset() is mandatory in the context of user IDs, because
       // user ID 0 denotes the anonymous user.
       if ($user = user_load_by_name($node->name)) {
-        $node->uid = $user->uid;
+        $node->uid = $user->id();
       }
       else {
         $node->uid = 0; // anonymous user
@@ -253,7 +253,7 @@ function node_revision_overview($node) {
     if ($revision->current_vid > 0) {
       $username = array(
         '#theme' => 'username',
-        '#account' => $revision,
+        '#account' => user_load($revision->uid),
       );
       $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid"), '!username' => drupal_render($username)))
                                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
@@ -263,7 +263,7 @@ function node_revision_overview($node) {
     else {
       $username = array(
         '#theme' => 'username',
-        '#account' => $revision,
+        '#account' => user_load($revision->uid),
       );
       $row[] = t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => drupal_render($username)))
                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index 8299456..6a9492c 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -17,13 +17,13 @@
 function node_access_test_node_grants($account, $op) {
   $grants = array();
   // First grant a grant to the author for own content.
-  $grants['node_access_test_author'] = array($account->uid);
+  $grants['node_access_test_author'] = array($account->id());
   if ($op == 'view' && user_access('node test view', $account)) {
     $grants['node_access_test'] = array(8888, 8889);
   }
 
   $no_access_uid = Drupal::state()->get('node_access_test.no_access_uid') ?: 0;
-  if ($op == 'view' && $account->uid == $no_access_uid) {
+  if ($op == 'view' && $account->id() == $no_access_uid) {
     $grants['node_access_all'] = array(0);
   }
   return $grants;
diff --git a/core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php b/core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php
index 18d9086..86ed1d0 100644
--- a/core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php
+++ b/core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php
@@ -78,7 +78,7 @@ public function onRequest(GetResponseEvent $event) {
 
     // Only act if the user has access to the overlay and a mode was not already
     // set. Other modules can also enable the overlay directly for other uses.
-    $user_data = $this->userData->get('overlay', $user->uid, 'enabled');
+    $user_data = $this->userData->get('overlay', $user->id(), 'enabled');
     $use_overlay = !isset($user_data) || $user_data;
     if (empty($mode) && user_access('access overlay') && $use_overlay) {
       $current_path = $request->attributes->get('system_path');
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 40a0c76..8a6a43a 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -237,7 +237,7 @@ function overlay_user_dismiss_message_access() {
   // It's unlikely, but possible that "access overlay" permission is granted to
   // the anonymous role. In this case, we do not display the message to disable
   // the overlay, so there is nothing to dismiss.
-  if (empty($user->uid)) {
+  if ($user->isAnonymous()) {
     return FALSE;
   }
   return TRUE;
@@ -263,10 +263,10 @@ function overlay_user_dismiss_message() {
     throw new AccessDeniedHttpException();
   }
 
-  Drupal::service('user.data')->set('overlay', $user->uid, 'message_dismissed', 1);
+  Drupal::service('user.data')->set('overlay', $user->id(), 'message_dismissed', 1);
   drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.'));
   // Destination is normally given. Go to the user profile as a fallback.
-  return new RedirectResponse(url('user/' . $user->uid . '/edit', array('absolute' => TRUE)));
+  return new RedirectResponse(url('user/' . $user->id() . '/edit', array('absolute' => TRUE)));
 }
 
 /**
@@ -286,11 +286,11 @@ function overlay_disable_message() {
   global $user;
 
   $build = array();
-  if (empty($user->uid) || !user_access('access overlay')) {
+  if ($user->isAnonymous() || !user_access('access overlay')) {
     return $build;
   }
 
-  $user_data = Drupal::service('user.data')->get('overlay', $user->uid);
+  $user_data = Drupal::service('user.data')->get('overlay', $user->id());
   if (empty($user_data['message_dismissed']) && (!isset($user_data['enabled']) || $user_data['enabled'])) {
     $build = array(
       '#theme' => 'overlay_disable_message',
@@ -299,7 +299,7 @@ function overlay_disable_message() {
       'profile_link' => array(
         '#type' => 'link',
         '#title' => t('If you have problems accessing administrative pages on this site, disable the overlay on your profile page.'),
-        '#href' => 'user/' . $user->uid . '/edit',
+        '#href' => 'user/' . $user->id() . '/edit',
         '#options' => array(
           'query' => drupal_get_destination(),
           'fragment' => 'edit-overlay-control',
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index 291b633..4e37019 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -115,7 +115,7 @@ function testAliasTranslation() {
 
     // Change user language preference.
     $edit = array('preferred_langcode' => 'fr');
-    $this->drupalPost("user/{$this->web_user->uid}/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $this->web_user->id() . "/edit", $edit, t('Save'));
 
     // Check that the English alias works. In this situation French is the
     // current UI and content language, while URL language is English (since we
diff --git a/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php b/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
index dd58116..88353ba 100644
--- a/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
+++ b/core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php
@@ -58,7 +58,7 @@ public function tips($long = FALSE) {
       $output .= '<li>' . t('<p>To display the name of a registered user, use this instead:</p>
   <pre>
   global $user;
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     print t(\'Welcome @name! Thank you for visiting.\', array(\'@name\' => user_format_name($user)));
   }
   else {
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
index 61b4b3d..345ae8c 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
@@ -109,8 +109,8 @@ public function setUp() {
    */
   public function testNumberOfCommentsRdfaMarkup() {
     // Posts 2 comments on behalf of registered user.
-    $this->saveComment($this->node->nid, $this->web_user->uid);
-    $this->saveComment($this->node->nid, $this->web_user->uid);
+    $this->saveComment($this->node->nid, $this->web_user->id());
+    $this->saveComment($this->node->nid, $this->web_user->id());
 
     // Tests number of comments in teaser view.
     $this->drupalLogin($this->web_user);
@@ -144,7 +144,7 @@ public function testNumberOfCommentsRdfaMarkup() {
    */
   public function testCommentRdfaMarkup() {
     // Posts comment #1 on behalf of registered user.
-    $comment1 = $this->saveComment($this->node->nid, $this->web_user->uid);
+    $comment1 = $this->saveComment($this->node->nid, $this->web_user->id());
 
     // Tests comment #1 with access to the user profile.
     $this->drupalLogin($this->web_user);
@@ -187,12 +187,12 @@ public function testCommentRdfaMarkup() {
   public function testCommentReplyOfRdfaMarkup() {
     // Posts comment #1 on behalf of registered user.
     $this->drupalLogin($this->web_user);
-    $comment_1 = $this->saveComment($this->node->nid, $this->web_user->uid);
+    $comment_1 = $this->saveComment($this->node->nid, $this->web_user->id());
 
     $comment_1_uri = url('comment/' . $comment_1->id(), array('absolute' => TRUE));
 
     // Posts a reply to the first comment.
-    $comment_2 = $this->saveComment($this->node->nid, $this->web_user->uid, NULL, $comment_1->id());
+    $comment_2 = $this->saveComment($this->node->nid, $this->web_user->id(), NULL, $comment_1->id());
     $comment_2_uri = url('comment/' . $comment_2->id(), array('absolute' => TRUE));
 
     $parser = new \EasyRdf_Parser_Rdfa();
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
index f7b797c..8ae8c1e 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php
@@ -96,7 +96,7 @@ public function setUp() {
     $page_uri_info = $this->page->uri();
     $this->pageUri = url($page_uri_info['path'], array('absolute' => TRUE));
     // Author.
-    $this->authorUri = url('user/' . $this->adminUser->uid, array('absolute' => TRUE));
+    $this->authorUri = url('user/' . $this->adminUser->id(), array('absolute' => TRUE));
     // Comment.
     $article_comment_uri_info = $this->articleComment->uri();
     $this->articleCommentUri = url($article_comment_uri_info['path'], array('absolute' => TRUE));
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php
index e380368..c5ba5f8 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php
@@ -53,15 +53,15 @@ function testUserAttributesInMarkup() {
     $user2 = $this->drupalCreateUser();
     $this->drupalLogin($user1);
 
-    $account_uri = url('user/' . $user2->uid, array('absolute' => TRUE));
-    $person_uri = url('user/' . $user2->uid, array('fragment' => 'me', 'absolute' => TRUE));
+    $account_uri = url('user/' . $user2->id(), array('absolute' => TRUE));
+    $person_uri = url('user/' . $user2->id(), array('fragment' => 'me', 'absolute' => TRUE));
 
     // Parses the user profile page where the default bundle mapping for user
     // should be used.
     $parser = new \EasyRdf_Parser_Rdfa();
     $graph = new \EasyRdf_Graph();
     $base_uri = url('<front>', array('absolute' => TRUE));
-    $parser->parse($graph, $this->drupalGet('user/' . $user2->uid), 'rdfa', $base_uri);
+    $parser->parse($graph, $this->drupalGet('user/' . $user2->id()), 'rdfa', $base_uri);
 
     // Inspects RDF graph output.
     // User type.
diff --git a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
index 584be0c..52a33ea 100644
--- a/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
+++ b/core/modules/rest/lib/Drupal/rest/Access/CSRFAccessCheck.php
@@ -50,7 +50,7 @@ public function access(Route $route, Request $request) {
     // 2. the user was successfully authenticated and
     // 3. the request comes with a session cookie.
     if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE'))
-      && user_is_logged_in()
+      && $GLOBALS['user']->isAuthenticated()
       && $cookie
     ) {
       $csrf_token = $request->headers->get('X-CSRF-Token');
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
index 46ad0cc..c8a4862 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']->uid,
+      'user_id' => $GLOBALS['user']->id(),
       'field_test_text' => array(
         'value' => $this->randomName(),
         'format' => 'full_html',
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php
index a7150b1..bae0e5c 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php
@@ -45,7 +45,7 @@ public function deleteAssignedShortcutSets(Shortcut $entity) {
    */
   public function assignUser($shortcut_set, $account) {
     db_merge('shortcut_set_users')
-      ->key(array('uid' => $account->uid))
+      ->key(array('uid' => $account->id()))
       ->fields(array('set_name' => $shortcut_set->id()))
       ->execute();
     drupal_static_reset('shortcut_current_displayed_set');
@@ -56,7 +56,7 @@ public function assignUser($shortcut_set, $account) {
    */
   public function unassignUser($account) {
     $deleted = db_delete('shortcut_set_users')
-      ->condition('uid', $account->uid)
+      ->condition('uid', $account->id())
       ->execute();
     return (bool) $deleted;
   }
@@ -67,7 +67,7 @@ public function unassignUser($account) {
   public function getAssignedToUser($account) {
     $query = db_select('shortcut_set_users', 'ssu');
     $query->fields('ssu', array('set_name'));
-    $query->condition('ssu.uid', $account->uid);
+    $query->condition('ssu.uid', $account->id());
     return $query->execute()->fetchField();
   }
 
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
index 8a55dfd..b02cd56 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
@@ -29,7 +29,7 @@ function testShortcutSetAdd() {
     $new_set = $this->generateShortcutSet($this->randomName());
     $sets = entity_load_multiple('shortcut');
     $this->assertTrue(isset($sets[$new_set->id()]), 'Successfully created a shortcut set.');
-    $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts');
     $this->assertText($new_set->label(), 'Generated shortcut set was listed as a choice on the user account page.');
   }
 
@@ -41,7 +41,7 @@ function testShortcutSetSwitchOwn() {
 
     // Attempt to switch the default shortcut set to the newly created shortcut
     // set.
-    $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', array('set' => $new_set->id()), t('Change set'));
+    $this->drupalPost('user/' . $this->admin_user->id() . '/shortcuts', array('set' => $new_set->id()), t('Change set'));
     $this->assertResponse(200);
     $current_set = shortcut_current_displayed_set($this->admin_user);
     $this->assertTrue($new_set->id() == $current_set->id(), 'Successfully switched own shortcut set.');
@@ -67,7 +67,7 @@ function testShortcutSetSwitchCreate() {
       'id' => strtolower($this->randomName()),
       'label' => $this->randomString(),
     );
-    $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set'));
+    $this->drupalPost('user/' . $this->admin_user->id() . '/shortcuts', $edit, t('Change set'));
     $current_set = shortcut_current_displayed_set($this->admin_user);
     $this->assertNotEqual($current_set->id(), $this->set->id(), 'A shortcut set can be switched to at the same time as it is created.');
     $this->assertEqual($current_set->label(), $edit['label'], 'The new set is correctly assigned to the user.');
@@ -78,7 +78,7 @@ function testShortcutSetSwitchCreate() {
    */
   function testShortcutSetSwitchNoSetName() {
     $edit = array('set' => 'new');
-    $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set'));
+    $this->drupalPost('user/' . $this->admin_user->id() . '/shortcuts', $edit, t('Change set'));
     $this->assertText(t('The new set label is required.'));
     $current_set = shortcut_current_displayed_set($this->admin_user);
     $this->assertEqual($current_set->id(), $this->set->id(), 'Attempting to switch to a new shortcut set without providing a set name does not succeed.');
@@ -167,7 +167,7 @@ function testShortcutSetCreateWithSetName() {
     $new_set = $this->generateShortcutSet($random_name, $random_name, TRUE);
     $sets = entity_load_multiple('shortcut');
     $this->assertTrue(isset($sets[$random_name]), 'Successfully created a shortcut set with a defined set name.');
-    $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts');
+    $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts');
     $this->assertText($new_set->label(), 'Generated shortcut set was listed as a choice on the user account page.');
   }
 }
diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc
index a75c4e1..1ad739d 100644
--- a/core/modules/shortcut/shortcut.admin.inc
+++ b/core/modules/shortcut/shortcut.admin.inc
@@ -55,7 +55,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) {
 
     $form['set'] = array(
       '#type' => 'radios',
-      '#title' => $user->uid == $account->uid ? t('Choose a set of shortcuts to use') : t('Choose a set of shortcuts for this user'),
+      '#title' => $user->id() == $account->id() ? t('Choose a set of shortcuts to use') : t('Choose a set of shortcuts for this user'),
       '#options' => $options,
       '#default_value' => $current_set->id(),
     );
@@ -85,7 +85,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) {
       '#required' => FALSE,
     );
 
-    if ($user->uid != $account->uid) {
+    if ($user->id() != $account->id()) {
       $default_set = shortcut_default_set($account);
       $form['new']['#description'] = t('The new set is created by copying items from the %default set.', array('%default' => $default_set->label()));
     }
@@ -147,7 +147,7 @@ function shortcut_set_switch_submit($form, &$form_state) {
       '%set_name' => $set->label(),
       '@switch-url' => url(current_path()),
     );
-    if ($account->uid == $user->uid) {
+    if ($account->id() == $user->id()) {
       // Only administrators can create new shortcut sets, so we know they have
       // access to switch back.
       drupal_set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="@switch-url">switch back to a different one.</a>', $replacements));
@@ -164,7 +164,7 @@ function shortcut_set_switch_submit($form, &$form_state) {
       '%user' => $account->name,
       '%set_name' => $set->label(),
     );
-    drupal_set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements));
+    drupal_set_message($account->id() == $user->id() ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements));
   }
 
   // Assign the shortcut set to the provided user account.
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index c58bf8a..3953cd4 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -32,7 +32,7 @@ function shortcut_help($path, $arg) {
     case 'admin/config/user-interface/shortcut':
     case 'admin/config/user-interface/shortcut/%':
       if (user_access('switch shortcut sets')) {
-        $output = '<p>' . t('Define which shortcut set you are using on the <a href="@shortcut-link">Shortcuts tab</a> of your account page.', array('@shortcut-link' => url("user/{$user->uid}/shortcuts"))) . '</p>';
+        $output = '<p>' . t('Define which shortcut set you are using on the <a href="@shortcut-link">Shortcuts tab</a> of your account page.', array('@shortcut-link' => url("user/{$user->id()}/shortcuts"))) . '</p>';
         return $output;
       }
   }
@@ -208,7 +208,7 @@ function shortcut_set_switch_access($account = NULL) {
     return FALSE;
   }
 
-  if (!isset($account) || $user->uid == $account->uid) {
+  if (!isset($account) || $user->id() == $account->id()) {
     // Users with the 'switch shortcut sets' permission can switch their own
     // shortcuts sets.
     return TRUE;
@@ -329,8 +329,8 @@ function shortcut_current_displayed_set($account = NULL) {
     $account = $user;
   }
   // Try to return a shortcut set from the static cache.
-  if (isset($shortcut_sets[$account->uid])) {
-    return $shortcut_sets[$account->uid];
+  if (isset($shortcut_sets[$account->id()])) {
+    return $shortcut_sets[$account->id()];
   }
   // If none was found, try to find a shortcut set that is explicitly assigned
   // to this user.
@@ -345,7 +345,7 @@ function shortcut_current_displayed_set($account = NULL) {
     $shortcut_set = shortcut_default_set($account);
   }
 
-  $shortcut_sets[$account->uid] = $shortcut_set;
+  $shortcut_sets[$account->id()] = $shortcut_set;
   return $shortcut_set;
 }
 
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 8e295b3..a390648 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -266,11 +266,11 @@ protected function drupalCreateNode(array $settings = array()) {
     // logged in user if available, or else the user running the test.
     if (!isset($settings['uid'])) {
       if ($this->loggedInUser) {
-        $settings['uid'] = $this->loggedInUser->uid;
+        $settings['uid'] = $this->loggedInUser->id();
       }
       else {
         global $user;
-        $settings['uid'] = $user->uid;
+        $settings['uid'] = $user->id();
       }
     }
 
@@ -482,8 +482,8 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL)
     $account = entity_create('user', $edit);
     $account->save();
 
-    $this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
-    if (empty($account->uid)) {
+    $this->assertTrue($account->id(), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
+    if (!$account->id()) {
       return FALSE;
     }
 
@@ -605,7 +605,7 @@ protected function checkPermissions(array $permissions, $reset = FALSE) {
    *   $this->drupalLogin($account);
    *   // Load real user object.
    *   $pass_raw = $account->pass_raw;
-   *   $account = user_load($account->uid);
+   *   $account = user_load($account->id());
    *   $account->pass_raw = $pass_raw;
    * @endcode
    *
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
index af45ffd..949206f 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
@@ -61,7 +61,7 @@ function setUp() {
     }
     $this->privileged_user = $this->drupalCreateUser(array('administer statistics', 'view post access counter', 'create page content'));
     $this->drupalLogin($this->privileged_user);
-    $this->test_node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privileged_user->uid));
+    $this->test_node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privileged_user->id()));
     $this->client = \Drupal::httpClient();
     $this->client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10)));
   }
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
index 86c7b42..76551c7 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
@@ -51,7 +51,7 @@ function setUp() {
     $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));
 
     // Ensure we have a node page to access.
-    $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid));
+    $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->id()));
 
     // Enable page caching.
     $config = config('system.performance');
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php
index b897f99..9a6b22f 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php
@@ -28,7 +28,7 @@ function testPopularContentBlock() {
     $this->container->get('plugin.manager.block')->clearCachedDefinitions();
 
     // Visit a node to have something show up in the block.
-    $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->blocking_user->uid));
+    $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->blocking_user->id()));
     $this->drupalGet('node/' . $node->nid);
     // Manually calling statistics.php, simulating ajax behavior.
     $nid = $node->nid;
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
index f13d5cb..56246cd 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
@@ -30,7 +30,7 @@ function testStatisticsTokenReplacement() {
     // Create user and node.
     $user = $this->drupalCreateUser(array('create page content'));
     $this->drupalLogin($user);
-    $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->uid));
+    $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->id()));
 
     // Hit the node.
     $this->drupalGet('node/' . $node->nid);
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
index 8e7879e..1daf4bf 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
@@ -29,7 +29,7 @@ class SystemMenuBlock extends BlockBase {
   public function access() {
     // @todo The 'Tools' menu should be available to anonymous users.
     list($plugin, $derivative) = explode(':', $this->getPluginId());
-    return ($GLOBALS['user']->uid || in_array($derivative, array('menu-main', 'menu-tools', 'menu-footer')));
+    return ($GLOBALS['user']->isAuthenticated() || in_array($derivative, array('menu-main', 'menu-tools', 'menu-footer')));
   }
 
   /**
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 af933e4..657ffb5 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -120,13 +120,13 @@ function testFormatDate() {
     $test_user = $this->drupalCreateUser();
     $this->drupalLogin($test_user);
     $edit = array('preferred_langcode' => self::LANGCODE, 'mail' => $test_user->mail, 'timezone' => 'America/Los_Angeles');
-    $this->drupalPost('user/' . $test_user->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $test_user->id() . '/edit', $edit, t('Save'));
 
     // Disable session saving as we are about to modify the global $user.
     drupal_save_session(FALSE);
     // Save the original user and language and then replace it with the test user and language.
     $real_user = $user;
-    $user = user_load($test_user->uid, TRUE);
+    $user = user_load($test_user->id(), TRUE);
     $real_language = $language_interface->id;
     $language_interface->id = $user->preferred_langcode;
     // Simulate a Drupal bootstrap with the logged-in user.
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 698ea1a..ea2b4db 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php
@@ -83,13 +83,13 @@ public function testDateTimezone() {
 
     // Set up the user with a different timezone than the site.
     $edit = array('mail' => $test_user->mail, 'timezone' => 'Asia/Manila');
-    $this->drupalPost('user/' . $test_user->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $test_user->id() . '/edit', $edit, t('Save'));
 
     // Disable session saving as we are about to modify the global $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->uid, TRUE);
+    $user = user_load($test_user->id(), TRUE);
 
     // Simulate a Drupal bootstrap with the logged-in user.
     date_default_timezone_set(drupal_get_user_timezone());
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php
index a9fd8bf..57f9355 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php
@@ -56,9 +56,9 @@ public function testCRUD() {
    */
   protected function assertCRUD($entity_type, UserInterface $user1) {
     // Create some test entities.
-    $entity = entity_create($entity_type, array('name' => 'test', 'user_id' => $user1->uid));
+    $entity = entity_create($entity_type, array('name' => 'test', 'user_id' => $user1->id()));
     $entity->save();
-    $entity = entity_create($entity_type, array('name' => 'test2', 'user_id' => $user1->uid));
+    $entity = entity_create($entity_type, array('name' => 'test2', 'user_id' => $user1->id()));
     $entity->save();
     $entity = entity_create($entity_type, array('name' => 'test', 'user_id' => NULL));
     $entity->save();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
index 055b014..4d98908 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
@@ -134,7 +134,7 @@ public function testCommentHooks() {
     $account = $this->createUser();
 
     $node = entity_create('node', array(
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'type' => 'article',
       'title' => 'Test node',
       'status' => 1,
@@ -154,7 +154,7 @@ public function testCommentHooks() {
       'cid' => NULL,
       'pid' => 0,
       'nid' => $nid,
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'subject' => 'Test comment',
       'created' => REQUEST_TIME,
       'changed' => REQUEST_TIME,
@@ -490,7 +490,7 @@ public function testUserHooks() {
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
-    user_load($account->uid);
+    user_load($account->id());
 
     $this->assertHookMessageOrder(array(
       'entity_crud_hook_test_entity_load called for type user',
@@ -509,7 +509,7 @@ public function testUserHooks() {
     ));
 
     $_SESSION['entity_crud_hook_test'] = array();
-    user_delete($account->uid);
+    user_delete($account->id());
 
     $this->assertHookMessageOrder(array(
       'entity_crud_hook_test_user_predelete called',
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
index e8878be..2c525a8 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
@@ -67,7 +67,7 @@ protected function createTestEntity($entity_type) {
     // Pass in the value of the name field when creating. With the user
     // field we test setting a field after creation.
     $entity = entity_create($entity_type, array());
-    $entity->user_id->target_id = $this->entity_user->uid;
+    $entity->user_id->target_id = $this->entity_user->id();
     $entity->name->value = $this->entity_name;
 
     // Set a value for the test field.
@@ -117,19 +117,19 @@ protected function assertReadWrite($entity_type) {
     $this->assertTrue($entity->user_id instanceof FieldInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type)));
     $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type)));
 
-    $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
 
     // Change the assigned user by entity.
     $new_user = $this->createUser();
     $entity->user_id->entity = $new_user;
-    $this->assertEqual($new_user->uid, $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($new_user->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($new_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
 
     // Change the assigned user by id.
     $new_user = $this->createUser();
-    $entity->user_id->target_id = $new_user->uid;
-    $this->assertEqual($new_user->uid, $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
+    $entity->user_id->target_id = $new_user->id();
+    $this->assertEqual($new_user->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($new_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type)));
 
     // Try unsetting a field.
@@ -207,7 +207,7 @@ protected function assertReadWrite($entity_type) {
     $this->entity_name = $this->randomName();
     $name_item[0]['value'] = $this->entity_name;
     $this->entity_user = $this->createUser();
-    $user_item[0]['target_id'] = $this->entity_user->uid;
+    $user_item[0]['target_id'] = $this->entity_user->id();
     $this->entity_field_text = $this->randomName();
     $text_item[0]['value'] = $this->entity_field_text;
 
@@ -217,7 +217,7 @@ protected function assertReadWrite($entity_type) {
       'field_test_text' => $text_item,
     ));
     $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
 
@@ -328,7 +328,7 @@ protected function assertSave($entity_type) {
     $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
-    $this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
+    $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
     $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
index 71b8141..90ac1da 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
@@ -109,7 +109,7 @@ public function setUp() {
       $entity = entity_create('entity_test', array());
       $entity->name->value = $this->randomName();
       $index = $i ? 1 : 0;
-      $entity->user_id->target_id = $this->accounts[$index]->uid;
+      $entity->user_id->target_id = $this->accounts[$index]->id();
       $entity->{$this->fieldName}->target_id = $this->terms[$index]->id();
       $entity->save();
       $this->entities[] = $entity;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityRevisionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityRevisionsTest.php
index 152527b..e2d31ab 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityRevisionsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityRevisionsTest.php
@@ -64,7 +64,7 @@ protected function assertRevisions($entity_type) {
     // Create initial entity.
     $entity = entity_create($entity_type, array(
       'name' => 'foo',
-      'user_id' => $this->web_user->uid,
+      'user_id' => $this->web_user->id(),
     ));
     $entity->field_test_text->value = 'bar';
     $entity->save();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
index 15d6fc3..9f78222 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -107,7 +107,7 @@ public function testEntityLanguageMethods() {
   protected function assertEntityLanguageMethods($entity_type) {
     $entity = entity_create($entity_type, array(
       'name' => 'test',
-      'user_id' => $GLOBALS['user']->uid,
+      'user_id' => $GLOBALS['user']->id(),
     ));
     $this->assertEqual($entity->language()->id, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
     $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
index f1a0fdb..f00a35b 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
@@ -72,7 +72,7 @@ protected function createTestEntity($entity_type) {
     // Pass in the value of the name field when creating. With the user
     // field we test setting a field after creation.
     $entity = entity_create($entity_type, array());
-    $entity->user_id->target_id = $this->entity_user->uid;
+    $entity->user_id->target_id = $this->entity_user->id();
     $entity->name->value = $this->entity_name;
 
     // Set a value for the test field.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
index fd1c08f..fdb3a70 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -384,17 +384,17 @@ function testBreadCrumbs() {
     // Verify breadcrumb on user pages (without menu link) for anonymous user.
     $trail = $home;
     $this->assertBreadcrumb('user', $trail, t('Log in'));
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->name);
 
     // Verify breadcrumb on user pages (without menu link) for registered users.
     $this->drupalLogin($this->admin_user);
     $trail = $home;
     $this->assertBreadcrumb('user', $trail, $this->admin_user->name);
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->name);
     $trail += array(
-      'user/' . $this->admin_user->uid => $this->admin_user->name,
+      'user/' . $this->admin_user->id() => $this->admin_user->name,
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $this->admin_user->name);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $this->admin_user->name);
 
     // Create a second user to verify breadcrumb on user pages again.
     $this->web_user = $this->drupalCreateUser(array(
@@ -406,23 +406,23 @@ function testBreadCrumbs() {
     // Verify correct breadcrumb and page title on another user's account pages
     // (without menu link).
     $trail = $home;
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $this->admin_user->name);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->name);
     $trail += array(
-      'user/' . $this->admin_user->uid => $this->admin_user->name,
+      'user/' . $this->admin_user->id() => $this->admin_user->name,
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $this->admin_user->name);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $this->admin_user->name);
 
     // Verify correct breadcrumb and page title when viewing own user account
     // pages (without menu link).
     $trail = $home;
-    $this->assertBreadcrumb('user/' . $this->web_user->uid, $trail, $this->web_user->name);
+    $this->assertBreadcrumb('user/' . $this->web_user->id(), $trail, $this->web_user->name);
     $trail += array(
-      'user/' . $this->web_user->uid => $this->web_user->name,
+      'user/' . $this->web_user->id() => $this->web_user->name,
     );
     $tree = array(
       'user' => t('My account'),
     );
-    $this->assertBreadcrumb('user/' . $this->web_user->uid . '/edit', $trail, $this->web_user->name, $tree);
+    $this->assertBreadcrumb('user/' . $this->web_user->id() . '/edit', $trail, $this->web_user->name, $tree);
 
     // Add a Tools menu links for 'user' and $this->admin_user.
     // Although it may be faster to manage these links via low-level API
@@ -438,7 +438,7 @@ function testBreadCrumbs() {
 
     $edit = array(
       'link_title' => $this->admin_user->name . ' link',
-      'link_path' => 'user/' . $this->admin_user->uid,
+      'link_path' => 'user/' . $this->admin_user->id(),
     );
     $this->drupalPost("admin/structure/menu/manage/$menu/add", $edit, t('Save'));
     $menu_links_admin_user = entity_load_multiple_by_properties('menu_link', array('link_title' => $edit['link_title'], 'link_path' => $edit['link_path']));
@@ -454,13 +454,13 @@ function testBreadCrumbs() {
     $tree = array(
       $link_admin_user['link_path'] => $link_admin_user['link_title'],
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $link_admin_user['link_title'], $tree);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $link_admin_user['link_title'], $tree);
 
     $this->drupalLogin($this->admin_user);
     $trail += array(
       $link_admin_user['link_path'] => $link_admin_user['link_title'],
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE);
 
     // Move 'user/%' below 'user' and verify again.
     $edit = array(
@@ -480,13 +480,13 @@ function testBreadCrumbs() {
     $tree += array(
       $link_admin_user['link_path'] => $link_admin_user['link_title'],
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid, $trail, $link_admin_user['link_title'], $tree);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $link_admin_user['link_title'], $tree);
 
     $this->drupalLogin($this->admin_user);
     $trail += array(
       $link_admin_user['link_path'] => $link_admin_user['link_title'],
     );
-    $this->assertBreadcrumb('user/' . $this->admin_user->uid . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE);
+    $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $link_admin_user['link_title'], $tree, FALSE);
 
     // Create an only slightly privileged user being able to access site reports
     // but not administration pages.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
index afb7e32..00b1634 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
@@ -205,11 +205,11 @@ function testAuthUserUserLogin() {
 
     $this->drupalGet('user/login');
     // Check that we got to 'user'.
-    $this->assertTrue($this->url == url('user/' . $this->loggedInUser->uid, array('absolute' => TRUE)), "Logged-in user redirected to user on accessing user/login");
+    $this->assertTrue($this->url == url('user/' . $this->loggedInUser->id(), array('absolute' => TRUE)), "Logged-in user redirected to user on accessing user/login");
 
     // user/register should redirect to user/UID/edit.
     $this->drupalGet('user/register');
-    $this->assertTrue($this->url == url('user/' . $this->loggedInUser->uid . '/edit', array('absolute' => TRUE)), "Logged-in user redirected to user/UID/edit on accessing user/register");
+    $this->assertTrue($this->url == url('user/' . $this->loggedInUser->id() . '/edit', array('absolute' => TRUE)), "Logged-in user redirected to user/UID/edit on accessing user/register");
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php b/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php
index 14a0422..d56ee5f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php
@@ -46,13 +46,13 @@ public function testUpcasting() {
     $foo = 'bar';
 
     // paramconverter_test/test_user_node_foo/{user}/{node}/{foo}
-    $this->drupalGet("paramconverter_test/test_user_node_foo/{$user->uid}/{$node->nid}/$foo");
+    $this->drupalGet("paramconverter_test/test_user_node_foo/"  . $user->id() . "/{$node->nid}/$foo");
     $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: $foo", 'user and node upcast by entity name');
 
     // paramconverter_test/test_node_user_user/{node}/{foo}/{user}
     // converters:
     //   foo: 'user'
-    $this->drupalGet("paramconverter_test/test_node_user_user/{$node->nid}/{$user->uid}/{$user->uid}");
+    $this->drupalGet("paramconverter_test/test_node_user_user/{$node->nid}/" . $user->id() . "/" . $user->id());
     $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}", 'foo converted to user as well');
 
     // paramconverter_test/test_node_node_foo/{user}/{node}/{foo}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
index eef40d4..201b58a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
@@ -36,7 +36,7 @@ function testUrlAlter() {
     $account = $this->drupalCreateUser(array('administer url aliases'));
     $this->drupalLogin($account);
 
-    $uid = $account->uid;
+    $uid = $account->id();
     $name = $account->name;
 
     // Test a single altered path.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
index b338b7b..e0e8e10 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
@@ -209,7 +209,7 @@ protected function testHttpsSession() {
     $this->drupalPost(NULL, $edit, t('Log in'));
 
     // Test that the user is also authenticated on the insecure site.
-    $this->drupalGet("user/{$user->uid}/edit");
+    $this->drupalGet("user/" . $user->id() . "/edit");
     $this->assertResponse(200);
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
index f96b13e..220e672 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
@@ -42,7 +42,7 @@ function testSessionSaveRegenerate() {
     $user = $this->drupalCreateUser(array('access content'));
 
     // Enable sessions.
-    $this->sessionReset($user->uid);
+    $this->sessionReset($user->id());
 
     // Make sure the session cookie is set as HttpOnly.
     $this->drupalLogin($user);
@@ -84,7 +84,7 @@ function testSessionSaveRegenerate() {
   function testDataPersistence() {
     $user = $this->drupalCreateUser(array('access content'));
     // Enable sessions.
-    $this->sessionReset($user->uid);
+    $this->sessionReset($user->id());
 
     $this->drupalLogin($user);
 
@@ -104,7 +104,7 @@ function testDataPersistence() {
 
     // Switch browser cookie to anonymous user, then back to user 1.
     $this->sessionReset();
-    $this->sessionReset($user->uid);
+    $this->sessionReset($user->id());
     $this->assertText($value_1, 'Session data persists through browser close.', 'Session');
 
     // Logout the user and make sure the stored value no longer persists.
@@ -129,13 +129,13 @@ function testDataPersistence() {
 
     // Login, the data should persist.
     $this->drupalLogin($user);
-    $this->sessionReset($user->uid);
+    $this->sessionReset($user->id());
     $this->drupalGet('session-test/get');
     $this->assertNoText($value_1, 'Session has persisted for an authenticated user after logging out and then back in.', 'Session');
 
     // Change session and create another user.
     $user2 = $this->drupalCreateUser(array('access content'));
-    $this->sessionReset($user2->uid);
+    $this->sessionReset($user2->id());
     $this->drupalLogin($user2);
   }
 
@@ -203,7 +203,7 @@ function testSessionWrite() {
     $this->drupalLogin($user);
 
     $sql = 'SELECT u.access, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE u.uid = :uid';
-    $times1 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
+    $times1 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
 
     // Before every request we sleep one second to make sure that if the session
     // is saved, its timestamp will change.
@@ -211,21 +211,21 @@ function testSessionWrite() {
     // Modify the session.
     sleep(1);
     $this->drupalGet('session-test/set/foo');
-    $times2 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
+    $times2 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
     $this->assertEqual($times2->access, $times1->access, 'Users table was not updated.');
     $this->assertNotEqual($times2->timestamp, $times1->timestamp, 'Sessions table was updated.');
 
     // Write the same value again, i.e. do not modify the session.
     sleep(1);
     $this->drupalGet('session-test/set/foo');
-    $times3 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
+    $times3 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
     $this->assertEqual($times3->access, $times1->access, 'Users table was not updated.');
     $this->assertEqual($times3->timestamp, $times2->timestamp, 'Sessions table was not updated.');
 
     // Do not change the session.
     sleep(1);
     $this->drupalGet('');
-    $times4 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
+    $times4 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
     $this->assertEqual($times4->access, $times3->access, 'Users table was not updated.');
     $this->assertEqual($times4->timestamp, $times3->timestamp, 'Sessions table was not updated.');
 
@@ -238,7 +238,7 @@ function testSessionWrite() {
     );
     $this->writeSettings($settings);
     $this->drupalGet('');
-    $times5 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
+    $times5 = db_query($sql, array(':uid' => $user->id()))->fetchObject();
     $this->assertNotEqual($times5->access, $times4->access, 'Users table was updated.');
     $this->assertNotEqual($times5->timestamp, $times4->timestamp, 'Sessions table was updated.');
   }
@@ -254,7 +254,7 @@ function testEmptySessionID() {
 
     // Reset the sid in {sessions} to a blank string. This may exist in the
     // wild in some cases, although we normally prevent it from happening.
-    db_query("UPDATE {sessions} SET sid = '' WHERE uid = :uid", array(':uid' => $user->uid));
+    db_query("UPDATE {sessions} SET sid = '' WHERE uid = :uid", array(':uid' => $user->id()));
     // Send a blank sid in the session cookie, and the session should no longer
     // be valid. Closing the curl handler will stop the previous session ID
     // from persisting.
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
index 7c8c85b..85c68ba 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php
@@ -49,7 +49,7 @@ function testAccessDenied() {
     // Use a custom 403 page.
     $this->drupalLogin($this->admin_user);
     $edit = array(
-      'site_403' => 'user/' . $this->admin_user->uid,
+      'site_403' => 'user/' . $this->admin_user->id(),
     );
     $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
index 4e79ae9..ae39a10 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php
@@ -81,7 +81,7 @@ function testMainContentFallback() {
 
     // Request a user* page and see if it is displayed.
     $this->drupalLogin($this->web_user);
-    $this->drupalGet('user/' . $this->web_user->uid . '/edit');
+    $this->drupalGet('user/' . $this->web_user->id() . '/edit');
     $this->assertField('mail', 'User interface still available.');
 
     // Enable the block module again.
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
index dde1822..a794f77 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
@@ -37,7 +37,7 @@ function testPageNotFound() {
 
     // Use a custom 404 page.
     $edit = array(
-      'site_404' => 'user/' . $this->admin_user->uid,
+      'site_404' => 'user/' . $this->admin_user->id(),
     );
     $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php
index 761adf2..a5a689c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php
@@ -112,8 +112,8 @@ function testSiteMaintenance() {
     );
     $this->drupalPost('user/password', $edit, t('E-mail new password'));
     $mails = $this->drupalGetMails();
-    $start = strpos($mails[0]['body'], 'user/reset/'. $this->user->uid);
-    $path = substr($mails[0]['body'], $start, 66 + strlen($this->user->uid));
+    $start = strpos($mails[0]['body'], 'user/reset/'. $this->user->id());
+    $path = substr($mails[0]['body'], $start, 66 + strlen($this->user->id()));
 
     // Log in with temporary login link.
     $this->drupalPost($path, array(), t('Log in'));
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 a220835..24dbb26 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -30,7 +30,7 @@ function testTokenReplacement() {
 
     // Create the initial objects.
     $account = $this->drupalCreateUser();
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
     $node->title = '<blink>Blinking Text</blink>';
     global $user;
     $language_interface = language(Language::TYPE_INTERFACE);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php
index b0e255e..3f625b1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php
@@ -64,7 +64,7 @@ function testUpdateAccess() {
     $user1 = user_load(1);
     $user1->pass_raw = user_password();
     $user1->pass = drupal_container()->get('password')->hash(trim($user1->pass_raw));
-    db_query("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(':pass' => $user1->pass, ':uid' => $user1->uid));
+    db_query("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(':pass' => $user1->pass, ':uid' => $user1->id()));
     $this->drupalLogin($user1);
     $this->drupalGet($this->update_url, array('external' => TRUE));
     $this->assertResponse(200);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
index 2ebeb66..d7052fa 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php
@@ -11,6 +11,7 @@
 use Drupal\Core\Database\Database;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\DrupalKernel;
+use Drupal\Core\Session\UserSession;
 use Drupal\simpletest\WebTestBase;
 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
 use Symfony\Component\HttpFoundation\Request;
@@ -148,15 +149,12 @@ protected function setUp() {
     // Ensure that the session is not written to the new environment and replace
     // the global $user session with uid 1 from the new test site.
     drupal_save_session(FALSE);
-    // Login as uid 1.
-    $user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
-    // Load roles for the user object.
-    $roles = array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID);
-    $result = db_query('SELECT rid, uid FROM {users_roles} WHERE uid = :uid', array(':uid' => 1));
-    foreach ($result as $record) {
-      $roles[$record->rid] = $record->rid;
-    }
-    $user->roles = $roles;
+    // Load values for uid 1.
+    $values = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchAssoc();
+    // Load rolest.
+    $values['roles'] = array_merge(array(DRUPAL_AUTHENTICATED_RID), db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => 1))->fetchCol());
+    // Create a new user session object.
+    $user = new UserSession($values);
 
     // Generate and set a D8-compatible session cookie.
     $this->prepareD8Session();
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 1e1bae3..82f0868 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -2175,7 +2175,7 @@ function hook_file_url_alter(&$uri) {
   global $user;
 
   // User 1 will always see the local file in this example.
-  if ($user->uid == 1) {
+  if ($user->id() == 1) {
     return;
   }
 
@@ -2646,11 +2646,11 @@ function hook_update_N(&$sandbox) {
     $user->name .= '!';
     db_update('users')
       ->fields(array('name' => $user->name))
-      ->condition('uid', $user->uid)
+      ->condition('uid', $user->id())
       ->execute();
 
     $sandbox['progress']++;
-    $sandbox['current_uid'] = $user->uid;
+    $sandbox['current_uid'] = $user->id();
   }
 
   $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
@@ -3074,7 +3074,7 @@ function hook_url_outbound_alter(&$path, &$options, $original_path) {
   // Instead of pointing to user/[uid]/edit, point to user/me/edit.
   if (preg_match('|^user/([0-9]*)/edit(/.*)?|', $path, $matches)) {
     global $user;
-    if ($user->uid == $matches[1]) {
+    if ($user->id() == $matches[1]) {
       $path = 'user/me/edit' . $matches[2];
     }
   }
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index a6a7786..e065b28 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -124,7 +124,7 @@ function system_help($path, $arg) {
       break;
     case 'admin/config/development/maintenance':
       global $user;
-      if ($user->uid == 1) {
+      if ($user->id() == 1) {
         return '<p>' . t('Use maintenance mode when making major updates, particularly if the updates could disrupt visitors or the update process. Examples include upgrading, importing or exporting content, modifying a theme, modifying content types, and making backups.') . '</p>';
       }
       break;
@@ -2438,7 +2438,7 @@ function system_user_login($account) {
   $config = config('system.timezone');
   // If the user has a NULL time zone, notify them to set a time zone.
   if (!$account->timezone && $config->get('user.configurable') && $config->get('user.warn')) {
-    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
+    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->id()/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
 
@@ -2457,11 +2457,11 @@ function system_user_timezone(&$form, &$form_state) {
   $form['timezone']['timezone'] = array(
     '#type' => 'select',
     '#title' => t('Time zone'),
-    '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? config('system.timezone')->get('default') : ''),
-    '#options' => system_time_zones($account->uid != $user->uid),
+    '#default_value' => isset($account->timezone) ? $account->timezone : ($account->id() == $user->id() ? config('system.timezone')->get('default') : ''),
+    '#options' => system_time_zones($account->id() != $user->id()),
     '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'),
   );
-  if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) {
+  if (!isset($account->timezone) && $account->id() == $user->id() && empty($form_state['input']['timezone'])) {
     $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
     $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
     drupal_add_library('system', 'drupal.timezone');
diff --git a/core/modules/system/tests/modules/database_test/database_test.module b/core/modules/system/tests/modules/database_test/database_test.module
index 0440082..9240f9f 100644
--- a/core/modules/system/tests/modules/database_test/database_test.module
+++ b/core/modules/system/tests/modules/database_test/database_test.module
@@ -232,7 +232,7 @@ function database_test_theme_tablesort($form, &$form_state) {
   $status = array(t('blocked'), t('active'));
   $accounts = array();
   foreach ($result as $account) {
-    $options[$account->uid] = array(
+    $options[$account->id()] = array(
       'username' => check_plain($account->name),
       'status' =>  $status[$account->status],
     );
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index 25ae931..cb56e2b 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -2262,7 +2262,7 @@ function form_test_user_register_form_rebuild($form, &$form_state) {
 function form_test_two_instances() {
   global $user;
   $node1 = entity_create('node', array(
-    'uid' => $user->uid,
+    'uid' => $user->id(),
     'name' => (isset($user->name) ? $user->name : ''),
     'type' => 'page',
     'langcode' => Language::LANGCODE_NOT_SPECIFIED,
diff --git a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessor.php b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessor.php
index b3611be..1632d5e 100644
--- a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessor.php
+++ b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessor.php
@@ -22,7 +22,7 @@ public function processInbound($path, Request $request) {
     if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) {
       if ($account = user_load_by_name($matches[1])) {
         $matches += array(2 => '');
-        $path = 'user/' . $account->uid . $matches[2];
+        $path = 'user/' . $account->id() . $matches[2];
       }
     }
 
diff --git a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessorTest.php b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessorTest.php
index e649f6d..a27c65c 100644
--- a/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessorTest.php
+++ b/core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessorTest.php
@@ -24,7 +24,7 @@ public function processInbound($path, Request $request) {
     if (preg_match('!^user/([^/]+)(/.*)?!', $path, $matches)) {
       if ($account = user_load_by_name($matches[1])) {
         $matches += array(2 => '');
-        $path = 'user/' . $account->uid . $matches[2];
+        $path = 'user/' . $account->id() . $matches[2];
       }
     }
 
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 51b7d25..e9f1afd 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -632,7 +632,7 @@ function toolbar_library_info() {
  */
 function _toolbar_get_subtree_hash() {
   global $user;
-  $cid = $user->uid . ':' . language(Language::TYPE_INTERFACE)->id;
+  $cid = $user->id() . ':' . language(Language::TYPE_INTERFACE)->id;
   if ($cache = cache('toolbar')->get($cid)) {
     $hash = $cache->data;
   }
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
index d9db513..76033fb 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
@@ -61,7 +61,7 @@ function testTrackerNodeAccess() {
     $this->drupalGet('tracker');
     $this->assertText($private_node->title, 'Private node is visible to user with private access.');
     $this->assertText($public_node->title, 'Public node is visible to user with private access.');
-    $this->drupalGet('user/' . $access_user->uid . '/track');
+    $this->drupalGet('user/' . $access_user->id() . '/track');
     $this->assertText($private_node->title, 'Private node is visible to user with private access.');
     $this->assertText($public_node->title, 'Public node is visible to user with private access.');
 
@@ -70,7 +70,7 @@ function testTrackerNodeAccess() {
     $this->drupalGet('tracker');
     $this->assertNoText($private_node->title, 'Private node is not visible to user without private access.');
     $this->assertText($public_node->title, 'Public node is visible to user without private access.');
-    $this->drupalGet('user/' . $access_user->uid . '/track');
+    $this->drupalGet('user/' . $access_user->id() . '/track');
     $this->assertNoText($private_node->title, 'Private node is not visible to user without private access.');
     $this->assertText($public_node->title, 'Public node is visible to user without private access.');
   }
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
index b68b722..baa48d0 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
@@ -91,22 +91,22 @@ function testTrackerUser() {
 
     $unpublished = $this->drupalCreateNode(array(
       'title' => $this->randomName(8),
-      'uid' => $this->user->uid,
+      'uid' => $this->user->id(),
       'status' => 0,
     ));
     $my_published = $this->drupalCreateNode(array(
       'title' => $this->randomName(8),
-      'uid' => $this->user->uid,
+      'uid' => $this->user->id(),
       'status' => 1,
     ));
     $other_published_no_comment = $this->drupalCreateNode(array(
       'title' => $this->randomName(8),
-      'uid' => $this->other_user->uid,
+      'uid' => $this->other_user->id(),
       'status' => 1,
     ));
     $other_published_my_comment = $this->drupalCreateNode(array(
       'title' => $this->randomName(8),
-      'uid' => $this->other_user->uid,
+      'uid' => $this->other_user->id(),
       'status' => 1,
     ));
     $comment = array(
@@ -115,7 +115,7 @@ function testTrackerUser() {
     );
     $this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
 
-    $this->drupalGet('user/' . $this->user->uid . '/track');
+    $this->drupalGet('user/' . $this->user->id() . '/track');
     $this->assertNoText($unpublished->label(), "Unpublished nodes do not show up in the users's tracker listing.");
     $this->assertText($my_published->label(), "Published nodes show up in the user's tracker listing.");
     $this->assertNoText($other_published_no_comment->label(), "Other user's nodes do not show up in the user's tracker listing.");
@@ -125,7 +125,7 @@ function testTrackerUser() {
     $admin_user = $this->drupalCreateUser(array('post comments', 'administer comments', 'access user profiles'));
     $this->drupalLogin($admin_user);
     $this->drupalPost('comment/1/edit', array('status' => COMMENT_NOT_PUBLISHED), t('Save'));
-    $this->drupalGet('user/' . $this->user->uid . '/track');
+    $this->drupalGet('user/' . $this->user->id() . '/track');
     $this->assertNoText($other_published_my_comment->label(), 'Unpublished comments are not counted on the tracker listing.');
   }
 
@@ -234,7 +234,7 @@ function testTrackerCronIndexing() {
     $this->drupalLogin($this->user);
 
     // Fetch the user's tracker.
-    $this->drupalGet('tracker/' . $this->user->uid);
+    $this->drupalGet('tracker/' . $this->user->id());
 
     // Assert that all node titles are displayed.
     foreach ($nodes as $i => $node) {
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 58de969..edcd297 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -171,7 +171,7 @@ function tracker_cron() {
  */
 function _tracker_myrecent_access($account) {
   // This path is only allowed for authenticated users looking at their own content.
-  return $account->uid && ($GLOBALS['user']->uid == $account->uid) && user_access('access content');
+  return $account->id() && ($GLOBALS['user']->id() == $account->id()) && user_access('access content');
 }
 
 /**
diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc
index 3d274e8..eabd7f4 100644
--- a/core/modules/tracker/tracker.pages.inc
+++ b/core/modules/tracker/tracker.pages.inc
@@ -22,7 +22,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
     $query = db_select('tracker_user', 't')
       ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
       ->addMetaData('base_table', 'tracker_user')
-      ->condition('t.uid', $account->uid);
+      ->condition('t.uid', $account->id());
 
     if ($set_title) {
       // When viewed from user/%user/track, display the name of the user
@@ -83,7 +83,7 @@ function tracker_page($account = NULL, $set_title = FALSE) {
         'type' => check_plain(node_get_type_label($node)),
         // Do not use $node->label(), because $node comes from the database.
         'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . drupal_render($mark_build)),
-        'author' => array('data' => array('#theme' => 'username', '#account' => $node)),
+        'author' => array('data' => array('#theme' => 'username', '#account' => user_load($node->uid))),
         'replies' => array('class' => array('replies'), 'data' => $comments),
         'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))),
       );
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index 9c88847..993cf13 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -154,7 +154,7 @@ function translation_user_can_translate_node($node, $account = NULL) {
   if (empty($account)) {
     $account = $GLOBALS['user'];
   }
-  return node_access('view', $node, $account) && (user_access('translate all content', $account) || ($node->uid == $account->uid && user_access('translate own content', $account)));
+  return node_access('view', $node, $account) && (user_access('translate all content', $account) || ($node->uid == $account->id() && user_access('translate own content', $account)));
 }
 
 /**
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index 2d03d49..3fce023 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -355,7 +355,7 @@ function _update_cron_notify() {
       $default_langcode = language_default()->id;
       foreach ($notify_list as $target) {
         if ($target_user = user_load_by_mail($target)) {
-          $target_langcode = user_preferred_langcode($target_user);
+          $target_langcode = $target_user->getPreferredLangcode();
         }
         else {
           $target_langcode = $default_langcode;
diff --git a/core/modules/user/lib/Drupal/user/Access/LoginStatusCheck.php b/core/modules/user/lib/Drupal/user/Access/LoginStatusCheck.php
index 7148709..c2bdc10 100644
--- a/core/modules/user/lib/Drupal/user/Access/LoginStatusCheck.php
+++ b/core/modules/user/lib/Drupal/user/Access/LoginStatusCheck.php
@@ -27,7 +27,7 @@ public function applies(Route $route) {
    * {@inheritdoc}
    */
   public function access(Route $route, Request $request) {
-    return (bool) $GLOBALS['user']->uid;
+    return (bool) $GLOBALS['user']->id();
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php
index 6505d29..950c341 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -24,7 +24,7 @@ public function form(array $form, array &$form_state) {
     $config = config('user.settings');
 
     $language_interface = language(Language::TYPE_INTERFACE);
-    $register = empty($account->uid);
+    $register = $account->isAnonymous();
     $admin = user_access('administer users');
 
     // Account information.
@@ -43,7 +43,7 @@ public function form(array $form, array &$form_state) {
       '#attributes' => array('class' => array('username'), 'autocorrect' => 'off', 'autocomplete' => 'off', 'autocapitalize' => 'off',
       'spellcheck' => 'false'),
       '#default_value' => (!$register ? $account->name : ''),
-      '#access' => ($register || ($user->uid == $account->uid && user_access('change own username')) || $admin),
+      '#access' => ($register || ($user->id() == $account->id() && user_access('change own username')) || $admin),
       '#weight' => -10,
     );
 
@@ -70,7 +70,7 @@ public function form(array $form, array &$form_state) {
 
       // To skip the current password field, the user must have logged in via a
       // one-time link and have the token in the URL.
-      $pass_reset = isset($_SESSION['pass_reset_' . $account->uid]) && isset($_GET['pass-reset-token']) && ($_GET['pass-reset-token'] == $_SESSION['pass_reset_' . $account->uid]);
+      $pass_reset = isset($_SESSION['pass_reset_' . $account->id()]) && isset($_GET['pass-reset-token']) && ($_GET['pass-reset-token'] == $_SESSION['pass_reset_' . $account->id()]);
       $protected_values = array();
       $current_pass_description = '';
 
@@ -84,7 +84,7 @@ public function form(array $form, array &$form_state) {
       }
 
       // The user must enter their current password to change to a new one.
-      if ($user->uid == $account->uid) {
+      if ($user->id() == $account->id()) {
         $form['account']['current_pass_required_values'] = array(
           '#type' => 'value',
           '#value' => $protected_values,
@@ -176,9 +176,9 @@ public function form(array $form, array &$form_state) {
       '#format' => isset($account->signature_format) ? $account->signature_format : NULL,
     );
 
-    $user_preferred_langcode = $register ? $language_interface->id : user_preferred_langcode($account);
+    $user_preferred_langcode = $register ? $language_interface->id : $account->getPreferredLangcode();
 
-    $user_preferred_admin_langcode = $register ? $language_interface->id : user_preferred_langcode($account, 'admin');
+    $user_preferred_admin_langcode = $register ? $language_interface->id : $account->getPreferredAdminLangcode();
 
     // Is default the interface language?
     include_once DRUPAL_ROOT . '/core/includes/language.inc';
@@ -259,7 +259,7 @@ public function validate(array $form, array &$form_state) {
       else {
         $name_taken = (bool) db_select('users')
         ->fields('users', array('uid'))
-        ->condition('uid', (int) $account->uid, '<>')
+        ->condition('uid', (int) $account->id(), '<>')
         ->condition('name', db_like($form_state['values']['name']), 'LIKE')
         ->range(0, 1)
         ->execute()
@@ -276,7 +276,7 @@ public function validate(array $form, array &$form_state) {
     if (!empty($mail)) {
       $mail_taken = (bool) db_select('users')
       ->fields('users', array('uid'))
-      ->condition('uid', (int) $account->uid, '<>')
+      ->condition('uid', (int) $account->id(), '<>')
       ->condition('mail', db_like($mail), 'LIKE')
       ->range(0, 1)
       ->execute()
@@ -284,7 +284,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']->uid) {
+        if ($GLOBALS['user']->isAuthenticated()) {
           form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $mail)));
         }
         else {
diff --git a/core/modules/user/lib/Drupal/user/Controller/UserController.php b/core/modules/user/lib/Drupal/user/Controller/UserController.php
index eb1dbde..cd63cb0 100644
--- a/core/modules/user/lib/Drupal/user/Controller/UserController.php
+++ b/core/modules/user/lib/Drupal/user/Controller/UserController.php
@@ -32,8 +32,8 @@ class UserController extends ContainerAware {
    */
   public function userPage(Request $request) {
     global $user;
-    if ($user->uid) {
-      $response = new RedirectResponse(url('user/' . $user->uid, array('absolute' => TRUE)));
+    if ($user->id()) {
+      $response = new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE)));
     }
     else {
       $response = drupal_get_form(UserLoginForm::create($this->container), $request);
diff --git a/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/user/lib/Drupal/user/EventSubscriber/MaintenanceModeSubscriber.php
index bfaee91..2c47414 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 (user_is_logged_in() && !user_access('access site in maintenance mode')) {
+      if ($GLOBALS['user']->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 (user_is_logged_in()) {
+    if ($GLOBALS['user']->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']->uid . '/edit', array('absolute' => TRUE))));
+        $event->setResponse(new RedirectResponse(url('user/' . $GLOBALS['user']->id() . '/edit', array('absolute' => TRUE))));
         return;
       }
     }
diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php
index 185a16f..186bd60 100644
--- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php
+++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php
@@ -87,7 +87,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU
       ),
     );
     // Allow logged in users to request this also.
-    if ($user->uid > 0) {
+    if ($user->isAuthenticated()) {
       $form['name']['#type'] = 'value';
       $form['name']['#value'] = $user->mail;
       $form['mail'] = array(
@@ -117,7 +117,7 @@ public function validateForm(array &$form, array &$form_state) {
       $users = $this->userStorageController->loadByProperties(array('name' => $name, 'status' => '1'));
     }
     $account = reset($users);
-    if (isset($account->uid)) {
+    if ($account->id()) {
       form_set_value(array('#parents' => array('account')), $account, $form_state);
     }
     else {
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 58e9e37..9fab45f 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
@@ -61,7 +61,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']->uid, $entities);
+    $this->tempStoreFactory->get('user_user_operations_cancel')->set($GLOBALS['user']->id(), $entities);
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
index 0cc09b7..d8c50e4 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php
@@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, array $configuratio
    * Overrides \Drupal\block\BlockBase::access().
    */
   public function access() {
-    return (!$GLOBALS['user']->uid && !(arg(0) == 'user' && !is_numeric(arg(1))));
+    return (!$GLOBALS['user']->id() && !(arg(0) == 'user' && !is_numeric(arg(1))));
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
index d7269a3..26be5ba 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Block/UserNewBlock.php
@@ -66,12 +66,12 @@ public function blockSubmit($form, &$form_state) {
    */
   public function build() {
     // Retrieve a list of new users who have accessed the site successfully.
-    $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchAll();
+    $uids = db_query_range('SELECT uid FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchCol();
     $build = array(
       '#theme' => 'item_list__user__new',
       '#items' => array(),
     );
-    foreach ($items as $account) {
+    foreach (user_load_multiple($uids) as $account) {
       $username = array(
         '#theme' => 'username',
         '#account' => $account,
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index 4f89128..413cdb7 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
@@ -52,134 +52,6 @@
 class User extends EntityNG implements UserInterface {
 
   /**
-   * The user ID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $uid;
-
-  /**
-   * The user UUID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $uuid;
-
-  /**
-   * The unique user name.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $name;
-
-  /**
-   * The user's password (hashed).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $pass;
-
-  /**
-   * The user's email address.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $mail;
-
-  /**
-   * The user's default theme.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $theme;
-
-  /**
-   * The user's signature.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $signature;
-
-  /**
-   * The user's signature format.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $signature_format;
-
-  /**
-   * The timestamp when the user was created.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $created;
-
-  /**
-   * The timestamp when the user last accessed the site. A value of 0 means the
-   * user has never accessed the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $access;
-
-  /**
-   * The timestamp when the user last logged in. A value of 0 means the user has
-   * never logged in.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $login;
-
-  /**
-   * Whether the user is active (1) or blocked (0).
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $status;
-
-  /**
-   * The user's timezone.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $timezone;
-
-  /**
-   * The user's langcode.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $langcode;
-
-  /**
-   * The user's preferred langcode for receiving emails and viewing the site.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $preferred_langcode;
-
-  /**
-   * The user's preferred langcode for viewing administration pages.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $preferred_admin_langcode;
-
-  /**
-   * The email address used for initial account creation.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $init;
-
-  /**
-   * The user's roles.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $roles;
-
-  /**
    * {@inheritdoc}
    */
   public function id() {
@@ -189,30 +61,6 @@ public function id() {
   /**
    * {@inheritdoc}
    */
-  protected function init() {
-    parent::init();
-    unset($this->access);
-    unset($this->created);
-    unset($this->init);
-    unset($this->login);
-    unset($this->mail);
-    unset($this->name);
-    unset($this->pass);
-    unset($this->preferred_admin_langcode);
-    unset($this->preferred_langcode);
-    unset($this->roles);
-    unset($this->signature);
-    unset($this->signature_format);
-    unset($this->status);
-    unset($this->theme);
-    unset($this->timezone);
-    unset($this->uid);
-    unset($this->uuid);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
   static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) {
     if (!isset($values['created'])) {
       $values['created'] = REQUEST_TIME;
@@ -260,7 +108,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']->uid) {
+        if ($this->id() == $GLOBALS['user']->id()) {
           drupal_session_regenerate();
         }
       }
@@ -300,6 +148,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
     $storage_controller->deleteUserRoles($uids);
   }
 
+
   /**
    * {@inheritdoc}
    */
@@ -336,7 +185,6 @@ public function getSecureSessionId() {
   public function getSessionData() {
     return array();
   }
-
   /**
    * {@inheritdoc}
    */
@@ -367,4 +215,182 @@ public function removeRole($rid) {
     $this->set('roles', array_diff($this->getRoles(), array($rid)));
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPassword() {
+    return $this->get('pass')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPassword($password) {
+    $this->get('pass')->value = $password;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEmail() {
+    return $this->get('mail')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setEmail($mail) {
+    $this->get('mail')->value = $mail;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultTheme() {
+    return $this->get('theme')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignature() {
+    return $this->get('signature')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignatureFormat() {
+    return $this->get('signature_format')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->get('created')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastAccessedTime() {
+    return $this->get('access')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastAccessTime($timestamp) {
+    $this->get('access')->value = $timestamp;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastLoginTime() {
+    return $this->get('login')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastLoginTime($timestamp) {
+    $this->get('login')->value = $timestamp;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isActive() {
+    return $this->get('status')->value == 1;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isBlocked() {
+    return $this->get('status')->value == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function activate() {
+    $this->get('status')->value = 1;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function block() {
+    $this->get('status')->value = 0;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTimeZone() {
+    return $this->get('timezone')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredLangcode($default = NULL) {
+    $language_list = language_list();
+    $preferred_langcode = $this->get('preferred_langcode')->value;
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->id;
+    }
+    else {
+      return $default ? $default : language_default()->id;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  function getPreferredAdminLangcode($default = NULL) {
+    $language_list = language_list();
+    $preferred_langcode = $this->get('preferred_admin_langcode')->value;
+    if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
+      return $language_list[$preferred_langcode]->id;
+    }
+    else {
+      return $default ? $default : language_default()->id;
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getInitialEmail() {
+    return $this->get('init')->value;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->id() > 0;
+  }
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->id() == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getUsername() {
+    $name = $this->get('name')->value ?: \Drupal::config('user.settings')->get('anonymous');
+    \Drupal::moduleHandler()->alter('user_format_name', $name, $this);
+    return $name;
+  }
+
 }
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 8ed758e..8ffac71 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
@@ -26,7 +26,7 @@ class CurrentUser extends ArgumentDefaultPluginBase {
 
   public function getArgument() {
     global $user;
-    return $user->uid;
+    return $user->id();
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php
index 45c4c2a..f58c641 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php
@@ -41,14 +41,14 @@ public function getArgument() {
     foreach (range(1, 3) as $i) {
       $user = menu_get_object('user', $i);
       if (!empty($user)) {
-        return $user->uid;
+        return $user->id();
       }
     }
 
     foreach (range(1, 3) as $i) {
       $user = menu_get_object('user_uid_optional', $i);
       if (!empty($user)) {
-        return $user->uid;
+        return $user->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 dc3b42b..d014602 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
@@ -112,7 +112,7 @@ 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']->uid) {
+        if ($argument == $GLOBALS['user']->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
@@ -124,7 +124,7 @@ public function validateArgument($argument) {
     }
     else {
       if ($type == 'name' || $type == 'either') {
-        $name = !empty($GLOBALS['user']->name) ? $GLOBALS['user']->name : config('user.settings')->get('anonymous');
+        $name = $GLOBALS['user']->getUserName() ?: config('user.settings')->get('anonymous');
         if ($argument == $name) {
           $account = clone $GLOBALS['user'];
         }
@@ -138,31 +138,28 @@ public function validateArgument($argument) {
     }
 
     if (!isset($account)) {
-      $account = $this->database->select('users', 'u')
-        ->fields('u', array('uid', 'name'))
+      $uid = $this->database->select('users', 'u')
+        ->fields('u', array('uid'))
         ->condition($condition, $argument)
         ->execute()
-        ->fetchObject();
-    }
-    if (empty($account)) {
-      // User not found.
-      return FALSE;
+        ->fetchField();
+
+      if ($uid === FALSE) {
+        // User not found.
+        return FALSE;
+      }
     }
+    $account = user_load($uid);
 
     // See if we're filtering users based on roles.
     if (!empty($this->options['restrict_roles']) && !empty($this->options['roles'])) {
       $roles = $this->options['roles'];
-      $account->roles = array();
-      $account->roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
-      foreach ($account->getRoles() as $rid) {
-        $account->roles[] = $rid;
-      }
-      if (!(bool) array_intersect($account->roles, $roles)) {
+      if (!(bool) array_intersect($account->getRoles(), $roles)) {
         return FALSE;
       }
     }
 
-    $this->argument->argument = $account->uid;
+    $this->argument->argument = $account->id();
     $this->argument->validated_title = check_plain(user_format_name($account));
     return TRUE;
   }
@@ -174,7 +171,7 @@ public function processSummaryArguments(&$args) {
     if ($this->options['type'] == 'name') {
       $users = user_load_multiple($args);
       foreach ($users as $uid => $account) {
-        $args[$uids_arg_keys[$uid]] = $account->name;
+        $args[$uids_arg_keys[$uid]] = $account->label();
       }
     }
   }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php
index b09e84a..f781756 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php
@@ -79,7 +79,7 @@ function render_link($data, $values) {
     $account->uid = $this->getValue($values, 'uid');
     $account->name = $this->getValue($values);
     if (!empty($this->options['link_to_user']) || !empty($this->options['overwrite_anonymous'])) {
-      if (!empty($this->options['overwrite_anonymous']) && !$account->uid) {
+      if (!empty($this->options['overwrite_anonymous']) && !$account->id()) {
         // This is an anonymous user, and we're overriting the text.
         return check_plain($this->options['anonymous_text']);
       }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php b/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php
index b344857..5e272a1 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php
@@ -155,7 +155,7 @@ public function adminSummary() {
     if ($this->value) {
       $result = entity_load_multiple_by_properties('user', array('uid' => $this->value));
       foreach ($result as $account) {
-        if ($account->uid) {
+        if ($account->id()) {
           $this->value_options[$account->id()] = $account->label();
         }
         else {
diff --git a/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php
index 484a4af..53b29b1 100644
--- a/core/modules/user/lib/Drupal/user/ProfileFormController.php
+++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php
@@ -22,7 +22,7 @@ protected function actions(array $form, array &$form_state) {
     $element['delete']['#type'] = 'submit';
     $element['delete']['#value'] = t('Cancel account');
     $element['delete']['#submit'] = array('user_edit_cancel_submit');
-    $element['delete']['#access'] = $account->uid > 1 && (($account->uid == $GLOBALS['user']->uid && user_access('cancel account')) || user_access('administer users'));
+    $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $GLOBALS['user']->id() && user_access('cancel account')) || user_access('administer users'));
 
     return $element;
   }
diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php
index 1b0b76f..116f6c2 100644
--- a/core/modules/user/lib/Drupal/user/RegisterFormController.php
+++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php
@@ -32,8 +32,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->uid) {
-      return new RedirectResponse(url('user/' . $user->uid, array('absolute' => TRUE)));
+    if (!$admin && $user->isAuthenticated()) {
+      return new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE)));
     }
 
     $form['#attached']['library'][] = array('system', 'jquery.cookie');
@@ -99,9 +99,9 @@ public function save(array $form, array &$form_state) {
     $account->save();
 
     $form_state['user'] = $account;
-    $form_state['values']['uid'] = $account->uid;
+    $form_state['values']['uid'] = $account->id();
 
-    watchdog('user', 'New user: %name %email.', array('%name' => $form_state['values']['name'], '%email' => '<' . $form_state['values']['mail'] . '>'), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->uid . '/edit'));
+    watchdog('user', 'New user: %name %email.', array('%name' => $form_state['values']['name'], '%email' => '<' . $form_state['values']['mail'] . '>'), WATCHDOG_NOTICE, l(t('edit'), 'user/' . $account->id() . '/edit'));
 
     // Add plain text password into user account to generate mail tokens.
     $account->password = $pass;
diff --git a/core/modules/user/lib/Drupal/user/TempStoreFactory.php b/core/modules/user/lib/Drupal/user/TempStoreFactory.php
index ddd1a75..e741048 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']->uid ?: session_id();
+      $owner = $GLOBALS['user']->id() ?: session_id();
     }
 
     // Store the data for this collection in the database.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
index 171d402..b9c01fa 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php
@@ -46,7 +46,7 @@ function testUserAdmin() {
     $this->assertText($admin_user->name, 'Found Admin user on admin users page');
 
     // Test for existence of edit link in table.
-    $link = l(t('Edit'), "user/$user_a->uid/edit", array('query' => array('destination' => 'admin/people')));
+    $link = l(t('Edit'), "user/" . $user_a->id() . "/edit", array('query' => array('destination' => 'admin/people')));
     $this->assertRaw($link, 'Found user A edit link on admin users page');
 
     // Filter the users by name/e-mail.
@@ -79,13 +79,13 @@ function testUserAdmin() {
     $this->assertText($user_c->name, 'User C on filtered by role on admin users page');
 
     // Test blocking of a user.
-    $account = user_load($user_c->uid);
+    $account = user_load($user_c->id());
     $this->assertEqual($account->status, 1, 'User C not blocked');
     $edit = array();
     $edit['action'] = 'user_block_user_action';
     $edit['user_bulk_form[1]'] = TRUE;
     $this->drupalPost('admin/people', $edit, t('Apply'));
-    $account = user_load($user_c->uid, TRUE);
+    $account = user_load($user_c->id(), TRUE);
     $this->assertEqual($account->status, 0, 'User C blocked');
 
     // Test filtering on admin page for blocked users
@@ -99,18 +99,18 @@ function testUserAdmin() {
     $editunblock['action'] = 'user_unblock_user_action';
     $editunblock['user_bulk_form[1]'] = TRUE;
     $this->drupalPost('admin/people', $editunblock, t('Apply'));
-    $account = user_load($user_c->uid, TRUE);
+    $account = user_load($user_c->id(), TRUE);
     $this->assertEqual($account->status, 1, 'User C unblocked');
     $this->assertMail("to", $account->mail, "Activation mail sent to user C");
 
     // Test blocking and unblocking another user from /user/[uid]/edit form and sending of activation mail
     $user_d = $this->drupalCreateUser(array());
-    $account1 = user_load($user_d->uid, TRUE);
-    $this->drupalPost('user/' . $account1->uid . '/edit', array('status' => 0), t('Save'));
-    $account1 = user_load($user_d->uid, TRUE);
+    $account1 = user_load($user_d->id(), TRUE);
+    $this->drupalPost('user/' . $account1->id() . '/edit', array('status' => 0), t('Save'));
+    $account1 = user_load($user_d->id(), TRUE);
     $this->assertEqual($account1->status, 0, 'User D blocked');
-    $this->drupalPost('user/' . $account1->uid . '/edit', array('status' => TRUE), t('Save'));
-    $account1 = user_load($user_d->uid, TRUE);
+    $this->drupalPost('user/' . $account1->id() . '/edit', array('status' => TRUE), t('Save'));
+    $account1 = user_load($user_d->id(), TRUE);
     $this->assertEqual($account1->status, 1, 'User D unblocked');
     $this->assertMail("to", $account1->mail, "Activation mail sent to user D");
   }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php
index bf8c988..776f383 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php
@@ -73,7 +73,7 @@ function testUserLoginBlock() {
     $this->drupalLogout();
     $this->drupalPost('http://example.com/', $edit, t('Log in'), array('external' => FALSE));
     // Check that we remain on the site after login.
-    $this->assertEqual(url('user/' . $user->uid, array('absolute' => TRUE)), $this->getUrl(), 'Redirected to user profile page after login from the frontpage');
+    $this->assertEqual(url('user/' . $user->id(), array('absolute' => TRUE)), $this->getUrl(), 'Redirected to user profile page after login from the frontpage');
   }
 
   /**
@@ -89,14 +89,14 @@ function testWhosOnlineBlock() {
     $user3 = $this->drupalCreateUser(array());
 
     // Update access of two users to be within the active timespan.
-    $this->updateAccess($user1->uid);
-    $this->updateAccess($user2->uid, REQUEST_TIME + 1);
+    $this->updateAccess($user1->id());
+    $this->updateAccess($user2->id(), REQUEST_TIME + 1);
 
     // Insert an inactive user who should not be seen in the block, and ensure
     // that the admin user used in setUp() does not appear.
     $inactive_time = REQUEST_TIME - $config['seconds_online'] - 1;
-    $this->updateAccess($user3->uid, $inactive_time);
-    $this->updateAccess($this->adminUser->uid, $inactive_time);
+    $this->updateAccess($user3->id(), $inactive_time);
+    $this->updateAccess($this->adminUser->id(), $inactive_time);
 
     // Test block output.
     $content = entity_view($block, 'block');
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index 15e9912..c45a21f 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -39,25 +39,25 @@ function testUserCancelWithoutPermission() {
     $account = $this->drupalCreateUser(array());
     $this->drupalLogin($account);
     // Load real user object.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
 
     // Create a node.
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
 
     // Attempt to cancel account.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->assertNoRaw(t('Cancel account'), 'No cancel account button displayed.');
 
     // Attempt bogus account cancellation request confirmation.
     $timestamp = $account->login;
-    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
     $this->assertResponse(403, 'Bogus cancelling request rejected.');
-    $account = user_load($account->uid);
+    $account = user_load($account->id());
     $this->assertTrue($account->status == 1, 'User account was not canceled.');
 
     // Confirm user's content has not been altered.
     $test_node = node_load($node->nid, TRUE);
-    $this->assertTrue(($test_node->uid == $account->uid && $test_node->status == 1), 'Node of the user has not been altered.');
+    $this->assertTrue(($test_node->uid == $account->id() && $test_node->status == 1), 'Node of the user has not been altered.');
   }
 
   /**
@@ -109,13 +109,13 @@ function testUserCancelInvalid() {
     $account = $this->drupalCreateUser(array('cancel account'));
     $this->drupalLogin($account);
     // Load real user object.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
 
     // Create a node.
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
 
     // Attempt to cancel account.
-    $this->drupalPost('user/' . $account->uid . '/edit', NULL, t('Cancel account'));
+    $this->drupalPost('user/' . $account->id() . '/edit', NULL, t('Cancel account'));
 
     // Confirm account cancellation.
     $timestamp = time();
@@ -124,21 +124,21 @@ function testUserCancelInvalid() {
 
     // Attempt bogus account cancellation request confirmation.
     $bogus_timestamp = $timestamp + 60;
-    $this->drupalGet("user/$account->uid/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login));
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login));
     $this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Bogus cancelling request rejected.');
-    $account = user_load($account->uid);
+    $account = user_load($account->id());
     $this->assertTrue($account->status == 1, 'User account was not canceled.');
 
     // Attempt expired account cancellation request confirmation.
     $bogus_timestamp = $timestamp - 86400 - 60;
-    $this->drupalGet("user/$account->uid/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login));
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login));
     $this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'Expired cancel account request rejected.');
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
     $this->assertTrue($account->status, 'User account was not canceled.');
 
     // Confirm user's content has not been altered.
     $test_node = node_load($node->nid, TRUE);
-    $this->assertTrue(($test_node->uid == $account->uid && $test_node->status == 1), 'Node of the user has not been altered.');
+    $this->assertTrue(($test_node->uid == $account->id() && $test_node->status == 1), 'Node of the user has not been altered.');
   }
 
   /**
@@ -152,10 +152,10 @@ function testUserBlock() {
     $this->drupalLogin($web_user);
 
     // Load real user object.
-    $account = user_load($web_user->uid, TRUE);
+    $account = user_load($web_user->id(), TRUE);
 
     // Attempt to cancel account.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your user name.'), 'Informs that all content will be remain as is.');
@@ -168,8 +168,8 @@ function testUserBlock() {
     $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.');
 
     // Confirm account cancellation request.
-    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
-    $account = user_load($account->uid, TRUE);
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
+    $account = user_load($account->id(), TRUE);
     $this->assertTrue($account->status == 0, 'User has been blocked.');
 
     // Confirm that the confirmation message made it through to the end user.
@@ -186,16 +186,16 @@ function testUserBlockUnpublish() {
     $account = $this->drupalCreateUser(array('cancel account'));
     $this->drupalLogin($account);
     // Load real user object.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
 
     // Create a node with two revisions.
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
     $settings = get_object_vars($node);
     $settings['revision'] = 1;
     $node = $this->drupalCreateNode($settings);
 
     // Attempt to cancel account.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'), 'Informs that all content will be unpublished.');
@@ -206,8 +206,8 @@ function testUserBlockUnpublish() {
     $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.');
 
     // Confirm account cancellation request.
-    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
-    $account = user_load($account->uid, TRUE);
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
+    $account = user_load($account->id(), TRUE);
     $this->assertTrue($account->status == 0, 'User has been blocked.');
 
     // Confirm user's content has been unpublished.
@@ -230,14 +230,14 @@ function testUserAnonymize() {
     $account = $this->drupalCreateUser(array('cancel account'));
     $this->drupalLogin($account);
     // Load real user object.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
 
     // Create a simple node.
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
 
     // Create a node with two revisions, the initial one belonging to the
     // cancelling user.
-    $revision_node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $revision_node = $this->drupalCreateNode(array('uid' => $account->id()));
     $revision = $revision_node->vid;
     $settings = get_object_vars($revision_node);
     $settings['revision'] = 1;
@@ -245,7 +245,7 @@ function testUserAnonymize() {
     $revision_node = $this->drupalCreateNode($settings);
 
     // Attempt to cancel account.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
     $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => config('user.settings')->get('anonymous'))), 'Informs that all content will be attributed to anonymous account.');
@@ -256,8 +256,8 @@ function testUserAnonymize() {
     $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.');
 
     // Confirm account cancellation request.
-    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
-    $this->assertFalse(user_load($account->uid, TRUE), 'User is not found in the database.');
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
+    $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.');
 
     // Confirm that user's content has been attributed to anonymous user.
     $test_node = node_load($node->nid, TRUE);
@@ -283,10 +283,10 @@ function testUserDelete() {
     $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'skip comment approval'));
     $this->drupalLogin($account);
     // Load real user object.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
 
     // Create a simple node.
-    $node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $node = $this->drupalCreateNode(array('uid' => $account->id()));
 
     // Create comment.
     $langcode = Language::LANGCODE_NOT_SPECIFIED;
@@ -303,7 +303,7 @@ function testUserDelete() {
 
     // Create a node with two revisions, the initial one belonging to the
     // cancelling user.
-    $revision_node = $this->drupalCreateNode(array('uid' => $account->uid));
+    $revision_node = $this->drupalCreateNode(array('uid' => $account->id()));
     $revision = $revision_node->vid;
     $settings = get_object_vars($revision_node);
     $settings['revision'] = 1;
@@ -311,7 +311,7 @@ function testUserDelete() {
     $revision_node = $this->drupalCreateNode($settings);
 
     // Attempt to cancel account.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Your account will be removed and all account information deleted. All of your content will also be deleted.'), 'Informs that all content will be deleted.');
@@ -322,8 +322,8 @@ function testUserDelete() {
     $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.');
 
     // Confirm account cancellation request.
-    $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
-    $this->assertFalse(user_load($account->uid, TRUE), 'User is not found in the database.');
+    $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login));
+    $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.');
 
     // Confirm that user's content has been deleted.
     $this->assertFalse(node_load($node->nid, TRUE), 'Node of the user has been deleted.');
@@ -349,7 +349,7 @@ function testUserCancelByAdmin() {
     $this->drupalLogin($admin_user);
 
     // Delete regular user.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertRaw(t('Are you sure you want to cancel the account %name?', array('%name' => $account->name)), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
@@ -357,7 +357,7 @@ function testUserCancelByAdmin() {
     // Confirm deletion.
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertRaw(t('%name has been deleted.', array('%name' => $account->name)), 'User deleted.');
-    $this->assertFalse(user_load($account->uid), 'User is not found in the database.');
+    $this->assertFalse(user_load($account->id()), 'User is not found in the database.');
   }
 
   /**
@@ -377,7 +377,7 @@ function testUserWithoutEmailCancelByAdmin() {
     $this->drupalLogin($admin_user);
 
     // Delete regular user without e-mail address.
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertRaw(t('Are you sure you want to cancel the account %name?', array('%name' => $account->name)), 'Confirmation form to cancel account displayed.');
     $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
@@ -385,7 +385,7 @@ function testUserWithoutEmailCancelByAdmin() {
     // Confirm deletion.
     $this->drupalPost(NULL, NULL, t('Cancel account'));
     $this->assertRaw(t('%name has been deleted.', array('%name' => $account->name)), 'User deleted.');
-    $this->assertFalse(user_load($account->uid), 'User is not found in the database.');
+    $this->assertFalse(user_load($account->id()), 'User is not found in the database.');
   }
 
   /**
@@ -405,7 +405,7 @@ function testMassUserCancelByAdmin() {
     $users = array();
     for ($i = 0; $i < 3; $i++) {
       $account = $this->drupalCreateUser(array());
-      $users[$account->uid] = $account;
+      $users[$account->id()] = $account;
     }
 
     // Cancel user accounts, including own one.
@@ -425,13 +425,13 @@ function testMassUserCancelByAdmin() {
     $status = TRUE;
     foreach ($users as $account) {
       $status = $status && (strpos($this->content, t('%name has been deleted.', array('%name' => $account->name))) !== FALSE);
-      $status = $status && !user_load($account->uid, TRUE);
+      $status = $status && !user_load($account->id(), TRUE);
     }
     $this->assertTrue($status, 'Users deleted and not found in the database.');
 
     // Ensure that admin account was not cancelled.
     $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), 'Account cancellation request mailed message displayed.');
-    $admin_user = user_load($admin_user->uid);
+    $admin_user = user_load($admin_user->id());
     $this->assertTrue($admin_user->status == 1, 'Administrative user is found in the database and enabled.');
 
     // Verify that uid 1's account was not cancelled.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserDeleteTest.php b/core/modules/user/lib/Drupal/user/Tests/UserDeleteTest.php
index 2b9442d..5626096 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserDeleteTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserDeleteTest.php
@@ -31,7 +31,7 @@ function testUserDeleteMultiple() {
     $user_b = $this->drupalCreateUser(array('access content'));
     $user_c = $this->drupalCreateUser(array('access content'));
 
-    $uids = array($user_a->uid, $user_b->uid, $user_c->uid);
+    $uids = array($user_a->id(), $user_b->id(), $user_c->id());
 
     // These users should have a role
     $query = db_select('users_roles', 'r');
@@ -44,7 +44,7 @@ function testUserDeleteMultiple() {
 
     $this->assertTrue($roles_created > 0, 'Role assigments created for new users and deletion of role assigments can be tested');
     // We should be able to load one of the users.
-    $this->assertTrue(user_load($user_a->uid), 'User is created and deltion of user can be tested');
+    $this->assertTrue(user_load($user_a->id()), 'User is created and deltion of user can be tested');
     // Delete the users.
     user_delete_multiple($uids);
     // Test if the roles assignments are deleted.
@@ -57,8 +57,8 @@ function testUserDeleteMultiple() {
       ->fetchField();
     $this->assertTrue($roles_after_deletion == 0, 'Role assigments deleted along with users');
     // Test if the users are deleted, user_load() will return FALSE.
-    $this->assertFalse(user_load($user_a->uid), format_string('User with id @uid deleted.', array('@uid' => $user_a->uid)));
-    $this->assertFalse(user_load($user_b->uid), format_string('User with id @uid deleted.', array('@uid' => $user_b->uid)));
-    $this->assertFalse(user_load($user_c->uid), format_string('User with id @uid deleted.', array('@uid' => $user_c->uid)));
+    $this->assertFalse(user_load($user_a->id()), format_string('User with id @uid deleted.', array('@uid' => $user_a->id())));
+    $this->assertFalse(user_load($user_b->id()), format_string('User with id @uid deleted.', array('@uid' => $user_b->id())));
+    $this->assertFalse(user_load($user_c->id()), format_string('User with id @uid deleted.', array('@uid' => $user_c->id())));
   }
 }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
index 178ddda..0c9ded0 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
@@ -33,42 +33,42 @@ function testUserEdit() {
 
     // Test that error message appears when attempting to use a non-unique user name.
     $edit['name'] = $user2->name;
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t('The name %name is already taken.', array('%name' => $edit['name'])));
 
     // Check that filling out a single password field does not validate.
     $edit = array();
     $edit['pass[pass1]'] = '';
     $edit['pass[pass2]'] = $this->randomName();
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
 
     $edit['pass[pass1]'] = $this->randomName();
     $edit['pass[pass2]'] = '';
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
 
     // Test that the error message appears when attempting to change the mail or
     // pass without the current password.
     $edit = array();
     $edit['mail'] = $this->randomName() . '@new.example.com';
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('E-mail address'))));
 
     $edit['current_pass'] = $user1->pass_raw;
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t("The changes have been saved."));
 
     // Test that the user must enter current password before changing passwords.
     $edit = array();
     $edit['pass[pass1]'] = $new_pass = $this->randomName();
     $edit['pass[pass2]'] = $new_pass;
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Password'))));
 
     // Try again with the current password.
     $edit['current_pass'] = $user1->pass_raw;
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t("The changes have been saved."));
 
     // Make sure the user can log in with their new password.
@@ -82,11 +82,11 @@ function testUserEdit() {
     $this->drupalLogin($user1);
 
     $config->set('password_strength', TRUE)->save();
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertRaw(t('Password strength:'), 'The password strength indicator is displayed.');
 
     $config->set('password_strength', FALSE)->save();
-    $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", $edit, t('Save'));
     $this->assertNoRaw(t('Password strength:'), 'The password strength indicator is not displayed.');
   }
 
@@ -102,7 +102,7 @@ function testUserWithoutEmailEdit() {
     // This user has no e-mail address.
     $user1->mail = '';
     $user1->save();
-    $this->drupalPost("user/$user1->uid/edit", array('mail' => ''), t('Save'));
+    $this->drupalPost("user/" . $user1->id() . "/edit", array('mail' => ''), t('Save'));
     $this->assertRaw(t("The changes have been saved."));
   }
 }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
index e06298f..6bdb9d0 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
@@ -34,7 +34,7 @@ function testUserEditedOwnAccount() {
     // Change own username.
     $edit = array();
     $edit['name'] = $this->randomName();
-    $this->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $account->id() . '/edit', $edit, t('Save'));
 
     // Log out.
     $this->drupalLogout();
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
index 13f6489..eb6f1c3 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
@@ -53,6 +53,6 @@ function testLabelCallback() {
    */
   function testUriCallback() {
     $uri = $this->account->uri();
-    $this->assertEqual('user/' . $this->account->uid, $uri['path'], 'Correct user URI.');
+    $this->assertEqual('user/' . $this->account->id(), $uri['path'], 'Correct user URI.');
   }
 }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
index 65e3c24..c89dd26 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
@@ -94,7 +94,7 @@ function testLocalUserCreation() {
 
     // Test if the admin can use the language selector and if the
     // correct language is was saved.
-    $user_edit = $langcode . '/user/' . $user->uid . '/edit';
+    $user_edit = $langcode . '/user/' . $user->id() . '/edit';
 
     $this->drupalLogin($admin_user);
     $this->drupalGet($user_edit);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
index 407bd22..e2adf72 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
@@ -57,7 +57,7 @@ function testUserLanguageConfiguration() {
 
     // Login as normal user and edit account settings.
     $this->drupalLogin($web_user);
-    $path = 'user/' . $web_user->uid . '/edit';
+    $path = 'user/' . $web_user->id() . '/edit';
     $this->drupalGet($path);
     // Ensure language settings widget is available.
     $this->assertText(t('Language'), 'Language selector available.');
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
index 36c5f47..4dd289b 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
@@ -115,7 +115,7 @@ function testPasswordRehashOnLogin() {
     $this->drupalLogin($account);
     $this->drupalLogout();
     // Load the stored user. The password hash should reflect $default_count_log2.
-    $account = user_load($account->uid);
+    $account = user_load($account->id());
     $this->assertIdentical($password_hasher->getCountLog2($account->pass), $default_count_log2);
 
     // Change the required number of iterations by loading a test-module
@@ -127,7 +127,7 @@ function testPasswordRehashOnLogin() {
     $account->pass_raw = $password;
     $this->drupalLogin($account);
     // Load the stored user, which should have a different password hash now.
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
     $this->assertIdentical($password_hasher->getCountLog2($account->pass), $overridden_count_log2);
   }
 
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
index 09a2cf4..9f87d04 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
@@ -37,7 +37,7 @@ public function setUp() {
     // Activate user by logging in.
     $this->drupalLogin($account);
 
-    $this->account = user_load($account->uid);
+    $this->account = user_load($account->id());
     $this->drupalLogout();
 
     // Set the last login time that is used to generate the one-time link so
@@ -45,7 +45,7 @@ public function setUp() {
     $account->login = REQUEST_TIME - mt_rand(10, 100000);
     db_update('users')
       ->fields(array('login' => $account->login))
-      ->condition('uid', $account->uid)
+      ->condition('uid', $account->id())
       ->execute();
   }
 
@@ -99,7 +99,7 @@ function testUserPasswordReset() {
     // Create a password reset link as if the request time was 60 seconds older than the allowed limit.
     $timeout = config('user.settings')->get('password_reset_timeout');
     $bogus_timestamp = REQUEST_TIME - $timeout - 60;
-    $_uid = $this->account->uid;
+    $_uid = $this->account->id();
     $this->drupalGet("user/reset/$_uid/$bogus_timestamp/" . user_pass_rehash($this->account->pass, $bogus_timestamp, $this->account->login));
     $this->assertText(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.');
   }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
index 282dd65..f4a0662 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
@@ -65,7 +65,7 @@ function testCreateDeletePicture() {
 
     // Delete the picture.
     $edit = array();
-    $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Remove'));
+    $this->drupalPost('user/' . $this->web_user->id() . '/edit', $edit, t('Remove'));
     $this->drupalPost(NULL, array(), t('Save'));
 
     // Call system_cron() to clean up the file. Make sure the timestamp
@@ -131,10 +131,10 @@ function testPictureOnNodeComment() {
    */
   function saveUserPicture($image) {
     $edit = array('files[user_picture_und_0]' => drupal_realpath($image->uri));
-    $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $this->web_user->id() . '/edit', $edit, t('Save'));
 
     // Load actual user data from database.
-    $account = user_load($this->web_user->uid, TRUE);
+    $account = user_load($this->web_user->id(), TRUE);
     return file_load($account->user_picture[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'], TRUE);
   }
 }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
index e612374..e6e37dc 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
@@ -38,13 +38,13 @@ function testAssignAndRemoveRole()  {
     $account = $this->drupalCreateUser();
 
     // Assign the role to the user.
-    $this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => $rid), t('Save'));
+    $this->drupalPost('user/' . $account->id() . '/edit', array("roles[$rid]" => $rid), t('Save'));
     $this->assertText(t('The changes have been saved.'));
     $this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.');
     $this->userLoadAndCheckRoleAssigned($account, $rid);
 
     // Remove the role from the user.
-    $this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => FALSE), t('Save'));
+    $this->drupalPost('user/' . $account->id() . '/edit', array("roles[$rid]" => FALSE), t('Save'));
     $this->assertText(t('The changes have been saved.'));
     $this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
     $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
@@ -69,12 +69,12 @@ function testCreateUserWithRole() {
     // Get the newly added user.
     $account = user_load_by_name($edit['name']);
 
-    $this->drupalGet('user/' . $account->uid . '/edit');
+    $this->drupalGet('user/' . $account->id() . '/edit');
     $this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.');
     $this->userLoadAndCheckRoleAssigned($account, $rid);
 
     // Remove the role again.
-    $this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => FALSE), t('Save'));
+    $this->drupalPost('user/' . $account->id() . '/edit', array("roles[$rid]" => FALSE), t('Save'));
     $this->assertText(t('The changes have been saved.'));
     $this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
     $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
@@ -92,7 +92,7 @@ function testCreateUserWithRole() {
    *   Defaults to TRUE.
    */
   private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
-    $account = user_load($account->uid, TRUE);
+    $account = user_load($account->id(), TRUE);
     if ($is_assigned) {
       $this->assertTrue(array_search($rid, $account->roles), 'The role is present in the user object.');
     }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
index 85925e7..a83a8ca 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
@@ -95,7 +95,7 @@ function testUserSignature() {
     $edit = array(
       'signature[value]' => $signature_text,
     );
-    $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save'));
+    $this->drupalPost('user/' . $this->web_user->id() . '/edit', $edit, t('Save'));
 
     // Verify that values were stored.
     $this->assertFieldByName('signature[value]', $edit['signature[value]'], 'Submitted signature text found.');
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
index 8b77915..79cc539 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php
@@ -60,7 +60,7 @@ function testUserTimeZone() {
     $edit = array();
     $edit['mail'] = $web_user->mail;
     $edit['timezone'] = 'America/Santiago';
-    $this->drupalPost("user/$web_user->uid/edit", $edit, t('Save'));
+    $this->drupalPost("user/" . $web_user->id() . "/edit", $edit, t('Save'));
     $this->assertText(t('The changes have been saved.'), 'Time zone changed to Santiago time.');
 
     // Confirm date format and time zone.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index 347f3d0..56f33c0 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -56,16 +56,16 @@ function testUserTokenReplacement() {
     $this->drupalLogout();
     $this->drupalLogin($user2);
 
-    $account = user_load($user1->uid);
-    $global_account = user_load($GLOBALS['user']->uid);
+    $account = user_load($user1->id());
+    $global_account = user_load($GLOBALS['user']->id());
 
     // Generate and test sanitized tokens.
     $tests = array();
-    $tests['[user:uid]'] = $account->uid;
+    $tests['[user:uid]'] = $account->id();
     $tests['[user:name]'] = check_plain(user_format_name($account));
     $tests['[user:mail]'] = check_plain($account->mail);
-    $tests['[user:url]'] = url("user/$account->uid", $url_options);
-    $tests['[user:edit-url]'] = url("user/$account->uid/edit", $url_options);
+    $tests['[user:url]'] = url("user/" . $account->id(), $url_options);
+    $tests['[user:edit-url]'] = url("user/" . $account->id() . "/edit", $url_options);
     $tests['[user:last-login]'] = format_date($account->login, 'medium', '', NULL, $language_interface->id);
     $tests['[user:last-login:short]'] = format_date($account->login, 'short', '', NULL, $language_interface->id);
     $tests['[user:created]'] = format_date($account->created, 'medium', '', NULL, $language_interface->id);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php
index 56dbc62..8379bbe 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php
@@ -57,7 +57,7 @@ function testUserValidateCurrentPassCustomForm() {
     $edit = array();
     $edit['user_form_test_field'] = $this->accessUser->name;
     $edit['current_pass'] = $this->accessUser->pass_raw;
-    $this->drupalPost('user_form_test_current_password/' . $this->accessUser->uid, $edit, t('Test'));
+    $this->drupalPost('user_form_test_current_password/' . $this->accessUser->id(), $edit, t('Test'));
     $this->assertText(t('The password has been validated and the form submitted successfully.'));
   }
 }
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 970e1c3..654d1d7 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php
@@ -41,7 +41,7 @@ public function test_plugin_argument_default_current_user() {
     $view = views_get_view('test_plugin_argument_default_current_user');
     $view->initHandlers();
 
-    $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->uid, 'Uid of the current user is used.');
+    $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.');
     // Switch back.
     $user = $admin;
     drupal_save_session(TRUE);
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php
index 0d89d47..6a1145e 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php
@@ -37,7 +37,7 @@ function testArgumentValidateUserUid() {
     $account = $this->account;
     // test 'uid' case
     $view = $this->view_argument_validate_user('uid');
-    $this->assertTrue($view->argument['null']->validateArgument($account->uid));
+    $this->assertTrue($view->argument['null']->validateArgument($account->id()));
     // Reset safed argument validation.
     $view->argument['null']->argument_validated = NULL;
     // Fail for a string variable since type is 'uid'
@@ -56,7 +56,7 @@ function testArgumentValidateUserName() {
     // Reset safed argument validation.
     $view->argument['null']->argument_validated = NULL;
     // Fail for a uid variable since type is 'name'
-    $this->assertFalse($view->argument['null']->validateArgument($account->uid));
+    $this->assertFalse($view->argument['null']->validateArgument($account->id()));
     // Reset safed argument validation.
     $view->argument['null']->argument_validated = NULL;
     // Fail for a valid string, but for a user that doesn't exist
@@ -71,7 +71,7 @@ function testArgumentValidateUserEither() {
     // Reset safed argument validation.
     $view->argument['null']->argument_validated = NULL;
     // Fail for a uid variable since type is 'name'
-    $this->assertTrue($view->argument['null']->validateArgument($account->uid));
+    $this->assertTrue($view->argument['null']->validateArgument($account->id()));
     // Reset safed argument validation.
     $view->argument['null']->argument_validated = NULL;
     // Fail for a valid string, but for a user that doesn't exist
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php
index 24be6f8..db9c51f 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php
@@ -40,7 +40,7 @@ public function testArgumentTitle() {
 
     // Tests a valid user.
     $account = $this->drupalCreateUser();
-    $this->executeView($view, array($account->uid));
+    $this->executeView($view, array($account->id()));
     $this->assertEqual($view->getTitle(), $account->label());
     $view->destroy();
   }
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php
index 4e9b95a..45f77b3 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php
@@ -172,7 +172,7 @@ public function testExposedFilter() {
     $this->assertNoRaw('Unable to find user');
     // The actual result should contain all of the user ids.
     foreach ($this->accounts as $account) {
-      $this->assertRaw($account->uid);
+      $this->assertRaw($account->id());
     }
   }
 
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php b/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php
index 34a0d83..c2b3a30 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php
@@ -36,11 +36,11 @@ public function testRelationship() {
     $map = array('node_users_nid' => 'nid', 'uid' => 'uid');
     $expected_result = array(
       array(
-        'uid' => $this->users[1]->uid,
+        'uid' => $this->users[1]->id(),
         'nid' => $this->nodes[1]->nid,
       ),
       array(
-        'uid' => $this->users[0]->uid,
+        'uid' => $this->users[0]->id(),
         'nid' => $this->nodes[0]->nid,
       ),
     );
diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php b/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php
index 6ea9454..88b1c78 100644
--- a/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php
+++ b/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php
@@ -43,7 +43,7 @@ protected function setUp() {
 
     $this->users[] = $this->drupalCreateUser();
     $this->users[] = user_load(1);
-    $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->uid));
+    $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->id()));
     $this->nodes[] = $this->drupalCreateNode(array('uid' => 1));
   }
 
diff --git a/core/modules/user/lib/Drupal/user/UserBCDecorator.php b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
index eed508b..4568f00 100644
--- a/core/modules/user/lib/Drupal/user/UserBCDecorator.php
+++ b/core/modules/user/lib/Drupal/user/UserBCDecorator.php
@@ -15,6 +15,13 @@
 class UserBCDecorator extends EntityBCDecorator implements UserInterface {
 
   /**
+   * The decorated user entity.
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $decorated;
+
+  /**
    * {@inheritdoc}
    */
   public function &__get($name) {
@@ -76,4 +83,166 @@ public function removeRole($rid) {
     $this->decorated->removeRole($rid);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getPassword() {
+    return $this->decorated->getPassword();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setPassword($password) {
+    $this->decorated->setPassword($password);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEmail() {
+    return $this->decorated->getEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setEmail($mail) {
+    $this->decorated->setEmail($mail);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDefaultTheme() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignature() {
+    return $this->decorated->getDefaultTheme();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSignatureFormat() {
+    return $this->decorated->getSignatureFormat();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCreatedTime() {
+    return $this->decorated->getCreatedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastAccessedTime() {
+    return $this->decorated->getLastAccessedTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastAccessTime($timestamp) {
+    $this->decorated->setLastAccessTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getLastLoginTime() {
+    return $this->decorated->getLastLoginTime();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setLastLoginTime($timestamp) {
+    $this->decorated->setLastLoginTime($timestamp);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isActive() {
+    $this->decorated->isActive();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isBlocked() {
+    return $this->decorated->isBlocked();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function activate() {
+    return $this->decorated->activate();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function block() {
+    return $this->decorated->block();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTimeZone() {
+    return $this->decorated->getTimeZone();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreferredLangcode($default = NULL) {
+    return $this->decorated->getPreferredLangcode($default);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getPreferredAdminLangcode($default = NULL) {
+    return $this->decorated->getPreferredAdminLangcode($default);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getInitialEmail() {
+    return $this->decorated->getInitialEmail();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAuthenticated() {
+    return $this->decorated->id() > 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function isAnonymous() {
+    return $this->decorated->id() == 0;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getUsername() {
+    return $this->decorated->getUsername();
+  }
+
+
 }
diff --git a/core/modules/user/lib/Drupal/user/UserInterface.php b/core/modules/user/lib/Drupal/user/UserInterface.php
index 4dc1481..fbede92 100644
--- a/core/modules/user/lib/Drupal/user/UserInterface.php
+++ b/core/modules/user/lib/Drupal/user/UserInterface.php
@@ -50,4 +50,152 @@ public function addRole($rid);
    */
   public function removeRole($rid);
 
+  /**
+   * Returns the hashed password.
+   *
+   * @return string
+   *   The hashed password.
+   */
+  public function getPassword();
+
+  /**
+   * Sets the user password.
+   *
+   * @param string $password
+   *   The new unhashed password.
+   */
+  public function setPassword($password);
+
+  /**
+   * Returns the e-mail address of the user.
+   *
+   * @return string
+   *   The e-mail address.
+   */
+  public function getEmail();
+
+  /**
+   * Sets the e-mail address of the user.
+   *
+   * @param string $mail
+   *   The new e-mail address of the user.
+   */
+  public function setEmail($mail);
+
+  /**
+   * Returns the default theme of the user.
+   *
+   * @return string
+   *   Name of the theme.
+   */
+  public function getDefaultTheme();
+
+  /**
+   * Returns the user signature.
+   *
+   * @todo: Convert this to a configurable field.
+   *
+   * @return string
+   *   The signature text.
+   */
+  public function getSignature();
+
+  /**
+   * Returns the signature format.
+   *
+   * @return string
+   *   Name of the filter format.
+   */
+  public function getSignatureFormat();
+
+  /**
+   * Returns the creation time of the user as a UNIX timestamp.
+   *
+   * @return int
+   *   Timestamp of the creation date.
+   */
+  public function getCreatedTime();
+
+  /**
+   * The timestamp when the user last accessed the site.
+   *
+   * A value of 0 means the user has never accessed the site.
+   *
+   * @return int
+   *   Timestamp of the last access.
+   */
+  public function getLastAccessedTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last accessed the site..
+   *
+   * @param int $timestamp
+   *   Timestamp of the last access.
+   */
+  public function setLastAccessTime($timestamp);
+
+  /**
+   * Returns the UNIX timestamp when the user last logged in.
+   *
+   * @return int
+   *   Timestamp of the last login time.
+   */
+  public function getLastLoginTime();
+
+  /**
+   * Sets the UNIX timestamp when the user last logged in.
+   *
+   * @param int $timestamp
+   *   Timestamp of the last login time.
+   */
+  public function setLastLoginTime($timestamp);
+
+  /**
+   * Returns TRUE if the user is active.
+   *
+   * @return bool
+   *   TRUE if the user is active, false otherwise.
+   */
+  public function isActive();
+
+  /**
+   * Returns TRUE if the user is blocked.
+   *
+   * @return bool
+   *   TRUE if the user is blocked, false otherwise.
+   */
+  public function isBlocked();
+
+  /**
+   * Activates the user.
+   *
+   * @return \Drupal\user\UserInterface
+   *   The called user entity.
+   */
+  public function activate();
+
+  /**
+   * Blocks the user.
+   *
+   * @return \Drupal\user\UserInterface
+   *   The called user entity.
+   */
+  public function block();
+
+  /**
+   * Returns the timezone of the user.
+   *
+   * @return string
+   *   Name of the timezone.
+   */
+  public function getTimeZone();
+
+  /**
+   * Returns the e-mail that was used when the user was registered.
+   *
+   * @return string
+   *   Initial e-mail address of the user.
+   */
+  public function getInitialEmail();
+
 }
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index a745bfa..bb486ff 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -41,7 +41,7 @@ function user_admin_account() {
   foreach ($result as $account) {
     $account = user_load($account->uid);
     $users_roles = array();
-    $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
+    $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->id()));
     foreach ($roles_result as $user_role) {
       $users_roles[] = $roles[$user_role->rid];
     }
@@ -54,7 +54,7 @@ function user_admin_account() {
       '#theme' => 'item_list',
       '#items' => $users_roles,
     );
-    $options[$account->uid] = array(
+    $options[$account->id()] = array(
       'username' => drupal_render($username),
       'status' => $status[$account->status],
       'roles' => drupal_render($item_list),
@@ -64,22 +64,22 @@ function user_admin_account() {
     $links = array();
     $links['edit'] = array(
       'title' => t('Edit'),
-      'href' => 'user/' . $account->uid . '/edit',
+      'href' => 'user/' . $account->id() . '/edit',
       'query' => $destination,
     );
     if (module_invoke('content_translation', 'translate_access', $account)) {
       $links['translate'] = array(
         'title' => t('Translate'),
-        'href' => 'user/' . $account->uid . '/translations',
+        'href' => 'user/' . $account->id() . '/translations',
         'query' => $destination,
       );
     }
-    $options[$account->uid]['operations']['data'] = array(
+    $options[$account->id()]['operations']['data'] = array(
       '#type' => 'operations',
       '#links' => $links,
     );
 
-    $options[$account->uid]['title']['data']['#title'] = check_plain($account->name);
+    $options[$account->id()]['title']['data']['#title'] = check_plain($account->name);
 
   }
 
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 2f337d9..edb2d6f 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -65,7 +65,7 @@ function hook_user_load($users) {
  */
 function hook_user_predelete($account) {
   db_delete('mytable')
-    ->condition('uid', $account->uid)
+    ->condition('uid', $account->id())
     ->execute();
 }
 
@@ -121,7 +121,7 @@ function hook_user_cancel($edit, $account, $method) {
       module_load_include('inc', 'node', 'node.admin');
       $nodes = db_select('node_field_data', 'n')
         ->fields('n', array('nid'))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute()
         ->fetchCol();
       node_mass_update($nodes, array('status' => 0), NULL, TRUE);
@@ -132,14 +132,14 @@ function hook_user_cancel($edit, $account, $method) {
       module_load_include('inc', 'node', 'node.admin');
       $nodes = db_select('node_field_data', 'n')
         ->fields('n', array('nid'))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute()
         ->fetchCol();
       node_mass_update($nodes, array('uid' => 0), NULL, TRUE);
       // Anonymize old revisions.
       db_update('node_field_revision')
         ->fields(array('uid' => 0))
-        ->condition('uid', $account->uid)
+        ->condition('uid', $account->id())
         ->execute();
       break;
   }
@@ -200,8 +200,8 @@ function hook_user_cancel_methods_alter(&$methods) {
  */
 function hook_user_format_name_alter(&$name, $account) {
   // Display the user's uid instead of name.
-  if (isset($account->uid)) {
-    $name = t('User !uid', array('!uid' => $account->uid));
+  if ($account->id()) {
+    $name = t('User !uid', array('!uid' => $account->id()));
   }
 }
 
@@ -244,7 +244,7 @@ function hook_user_presave($account) {
 function hook_user_insert($account) {
   db_insert('user_changes')
     ->fields(array(
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'created' => time(),
     ))
     ->execute();
@@ -271,7 +271,7 @@ function hook_user_insert($account) {
 function hook_user_update($account) {
   db_insert('user_changes')
     ->fields(array(
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'changed' => time(),
     ))
     ->execute();
@@ -287,7 +287,7 @@ function hook_user_login($account) {
   $config = config('system.timezone');
   // If the user has a NULL time zone, notify them to set a time zone.
   if (!$account->timezone && $config->get('user.configurable') && $config->get('user.warn')) {
-    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
+    drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/" . $account->id() . "/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
   }
 }
 
@@ -300,7 +300,7 @@ function hook_user_login($account) {
 function hook_user_logout($account) {
   db_insert('logouts')
     ->fields(array(
-      'uid' => $account->uid,
+      'uid' => $account->id(),
       'time' => time(),
     ))
     ->execute();
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 37dc770..871c18d 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -640,7 +640,7 @@ function user_update_8011() {
         'uri' => $destination,
       ))
       ->fields(array(
-        'uid' => $user->uid,
+        'uid' => $user->id(),
         'status' => FILE_STATUS_PERMANENT,
         'filename' => drupal_basename($destination),
         'uuid' => $uuid->generate(),
@@ -800,7 +800,7 @@ function user_update_8012(&$sandbox) {
 
       // Update file usage from user to file module.
       // @see file_field_insert()
-      // Old: file_usage_add($picture, 'user', 'user', $entity->uid);
+      // Old: file_usage_add($picture, 'user', 'user', $entity->id();
       // New: file_usage_add(file_load($item['fid']), 'file', $entity_type, $id);
       db_update('file_usage')
         ->condition('fid', $fid)
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 05a516a..db9f833 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -159,7 +159,7 @@ function user_uri($user) {
  * @see user_format_name()
  */
 function user_label($entity_type, $entity) {
-  return user_format_name($entity->getBCEntity());
+  return $entity->getUsername();
 }
 
 /**
@@ -462,11 +462,8 @@ function user_access($string, AccountInterface $account = NULL) {
     $account = Drupal::request()->attributes->get('account') ?: $user;
   }
 
-  // Make sure we are working with the BC decorator.
-  $account = $account instanceof User ? $account->getBCEntity() : $account;
-
   // User #1 has all privileges:
-  if ($account->uid == 1) {
+  if ($account->id() == 1) {
     return TRUE;
   }
 
@@ -478,14 +475,14 @@ function user_access($string, AccountInterface $account = NULL) {
     $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
   }
   $perm = &$drupal_static_fast['perm'];
-  if (!isset($perm[$account->uid])) {
-    $perm[$account->uid] = array();
+  if (!isset($perm[$account->id()])) {
+    $perm[$account->id()] = array();
     foreach (user_role_permissions($account->getRoles()) as $role_permissions) {
-      $perm[$account->uid] += array_fill_keys($role_permissions, TRUE);
+      $perm[$account->id()] += array_fill_keys($role_permissions, TRUE);
     }
   }
 
-  return isset($perm[$account->uid][$string]);
+  return isset($perm[$account->id()][$string]);
 }
 
 /**
@@ -586,10 +583,10 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
   foreach ($accounts as $account) {
     $result = array(
       'title' => user_format_name($account),
-      'link' => url('user/' . $account->uid, array('absolute' => TRUE)),
+      'link' => url('user/' . $account->id(), array('absolute' => TRUE)),
     );
     if (user_access('administer users')) {
-      $result['title'] .= ' (' . $account->mail . ')';
+      $result['title'] .= ' (' . $account->getEmail() . ')';
     }
     $results[] = $result;
   }
@@ -666,25 +663,18 @@ function user_preprocess_block(&$variables) {
 /**
  * Format a username.
  *
- * By default, the passed-in object's 'name' property is used if it exists, or
- * else, the site-defined value for the 'anonymous' variable. However, a module
- * may override this by implementing
- * hook_user_format_name_alter(&$name, $account).
- *
- * @see hook_user_format_name_alter()
- *
- * @param $account
+ * @param \Drupal\Core\Session\Interface $account
  *   The account object for the user whose name is to be formatted.
  *
  * @return
  *   An unsanitized string with the username to display. The code receiving
  *   this result must ensure that check_plain() is called on it before it is
  *   printed to the page.
+ *
+ * @deprecated Use \Drupal\Core\Session\Interface::getUsername() instead.
  */
-function user_format_name($account) {
-  $name = !empty($account->name) ? $account->name : config('user.settings')->get('anonymous');
-  drupal_alter('user_format_name', $name, $account);
-  return $name;
+function user_format_name(AccountInterface $account) {
+  return $account->getUsername();
 }
 
 /**
@@ -707,7 +697,7 @@ function user_template_preprocess_default_variables_alter(&$variables) {
   unset($variables['user']->pass, $variables['user']->sid, $variables['user']->ssid);
 
   $variables['is_admin'] = user_access('access administration pages');
-  $variables['logged_in'] = ($user->uid > 0);
+  $variables['logged_in'] = $user->isAuthenticated();
 }
 
 /**
@@ -720,20 +710,14 @@ function user_template_preprocess_default_variables_alter(&$variables) {
  * @see template_process_username()
  */
 function template_preprocess_username(&$variables) {
-  $account = $variables['account'];
-  if ($account instanceof User) {
-    $account = $account->getBCEntity();
-  }
+  $account = $variables['account'] ?: drupal_anonymous_user();
 
   $variables['extra'] = '';
-  if (empty($account->uid)) {
-   $variables['uid'] = 0;
-   if (theme_get_setting('features.comment_user_verification')) {
-     $variables['extra'] = ' (' . t('not verified') . ')';
-   }
-  }
-  else {
-    $variables['uid'] = (int) $account->uid;
+  $variables['uid'] = $account->id();
+  if (empty($variables['uid'])) {
+    if (theme_get_setting('features.comment_user_verification')) {
+      $variables['extra'] = ' (' . t('not verified') . ')';
+    }
   }
 
   // Set the name to a formatted name that is safe for printing and
@@ -741,7 +725,7 @@ function template_preprocess_username(&$variables) {
   // unsanitized version, in case other preprocess functions want to implement
   // their own shortening logic or add markup. If they do so, they must ensure
   // that $variables['name'] is safe for printing.
-  $name = $variables['name_raw'] = user_format_name($account);
+  $name = $variables['name_raw'] = $account->getUsername();
   if (drupal_strlen($name) > 20) {
     $name = drupal_substr($name, 0, 15) . '...';
   }
@@ -810,7 +794,7 @@ function theme_username($variables) {
  */
 function user_is_anonymous() {
   // Menu administrators can see items for anonymous when administering.
-  return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
+  return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
 }
 
 /**
@@ -818,9 +802,11 @@ function user_is_anonymous() {
  *
  * @return bool
  *   TRUE if the user is logged in, FALSE if the user is anonymous.
+ *
+ * @deprecated Use \Drupal\Core\Session\UserSession::isAuthenticated().
  */
 function user_is_logged_in() {
-  return (bool) $GLOBALS['user']->uid;
+  return $GLOBALS['user']->isAuthenticated();
 }
 
 /**
@@ -1043,7 +1029,7 @@ function user_menu_breadcrumb_alter(&$active_trail, $item) {
 function user_menu_link_load($menu_links) {
   // Hide the "User account" link for anonymous users.
   foreach ($menu_links as $link) {
-    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->uid) {
+    if ($link['link_path'] == 'user' && $link['module'] == 'system' && !$GLOBALS['user']->id()) {
       $link['hidden'] = 1;
     }
   }
@@ -1089,7 +1075,7 @@ function user_uid_only_optional_to_arg($arg) {
  */
 function user_uid_optional_load($uid = NULL) {
   if (!isset($uid)) {
-    $uid = $GLOBALS['user']->uid;
+    $uid = $GLOBALS['user']->id();
   }
   return user_load($uid);
 }
@@ -1103,7 +1089,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']->uid : $arg;
+  return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
 }
 
 /**
@@ -1113,7 +1099,7 @@ function user_uid_optional_to_arg($arg) {
  * authenticated users are expected to see "My account".
  */
 function user_menu_title() {
-  if (!user_is_logged_in()) {
+  if ($GLOBALS['user']->isAnonymous()) {
     switch (current_path()) {
       case 'user' :
       case 'user/login' :
@@ -1134,8 +1120,8 @@ function user_menu_title() {
 /**
  * Menu item title callback - use the user name.
  */
-function user_page_title($account) {
-  return is_object($account) ? user_format_name($account) : '';
+function user_page_title(UserInterface $account = NULL) {
+  return $account ? $account->getUsername() : '';
 }
 
 /**
@@ -1178,11 +1164,11 @@ function user_authenticate($name, $password) {
       $password_hasher = drupal_container()->get('password');
       if ($password_hasher->check($password, $account)) {
         // Successful authentication.
-        $uid = $account->uid;
+        $uid = $account->id();
 
         // Update user to new password scheme if needed.
         if ($password_hasher->userNeedsNewHash($account)) {
-          $account->pass = $password;
+          $account->setPassword($password);
           $account->save();
         }
       }
@@ -1200,21 +1186,21 @@ function user_authenticate($name, $password) {
  *
  * The global $user object is replaced with the passed in account.
  *
- * @param \Drupal\Core\Session\AccountInterface $account
+ * @param \Drupal\user\UserInterface $account
  *   The account to log in.
  *
  * @see hook_user_login()
  */
-function user_login_finalize(AccountInterface $account) {
+function user_login_finalize(UserInterface $account) {
   global $user;
   $user = $account;
-  watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
+  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.
-  $user->login = REQUEST_TIME;
+  $account->setLastLoginTime(REQUEST_TIME);
   db_update('users')
-    ->fields(array('login' => $user->login))
-    ->condition('uid', $user->uid)
+    ->fields(array('login' => $user->getLastLoginTime()))
+    ->condition('uid', $user->id())
     ->execute();
 
   // Regenerate the session ID to prevent against session fixation attacks.
@@ -1262,9 +1248,9 @@ function user_user_logout($account) {
  */
 function user_pass_reset_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/reset/" . $account->id() . "/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime()), $url_options);
 }
 
 /**
@@ -1290,9 +1276,9 @@ function user_pass_reset_url($account, $options = array()) {
  */
 function user_cancel_url($account, $options = array()) {
   $timestamp = REQUEST_TIME;
-  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
+  $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode();
   $url_options = array('absolute' => TRUE, 'language' => language_load($langcode));
-  return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
+  return url("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->login), $url_options);
 }
 
 /**
@@ -1371,7 +1357,7 @@ function user_cancel($edit, $uid, $method) {
   );
 
   // After cancelling account, ensure that user is logged out.
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->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';
@@ -1414,7 +1400,7 @@ function _user_cancel($edit, $account, $method) {
       if (!empty($edit['user_cancel_notify'])) {
         _user_mail_notify('status_canceled', $account);
       }
-      user_delete($account->uid);
+      $account->delete();
       drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
       watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
       break;
@@ -1424,7 +1410,7 @@ 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->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     $user = drupal_anonymous_user();
   }
 
@@ -1808,7 +1794,7 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
 
 function user_multiple_cancel_confirm($form, &$form_state) {
   // Retrieve the accounts to be canceled from the temp store.
-  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->uid);
+  $accounts = Drupal::service('user.tempstore')->get('user_user_operations_cancel')->get($GLOBALS['user']->id());
   $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
   foreach ($accounts as $account) {
     $uid = $account->id();
@@ -1876,7 +1862,7 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
   global $user;
 
   // Clear out the accounts from the temp store.
-  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->uid);
+  Drupal::service('user.tempstore')->get('user_user_operations_cancel')->delete($user->id());
   if ($form_state['values']['confirm']) {
     foreach ($form_state['values']['accounts'] as $uid => $value) {
       // Prevent programmatic form submissions from cancelling user 1.
@@ -1884,12 +1870,12 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
         continue;
       }
       // Prevent user administrators from deleting themselves without confirmation.
-      if ($uid == $user->uid) {
+      if ($uid == $user->id()) {
         $admin_form_state = $form_state;
         unset($admin_form_state['values']['user_cancel_confirm']);
         // The $user global is not a complete user entity, so load the full
         // entity.
-        $admin_form_state['values']['_account'] = user_load($user->uid);
+        $admin_form_state['values']['_account'] = user_load($user->id());
         user_cancel_confirm_form_submit(array(), $admin_form_state);
       }
       else {
@@ -1924,40 +1910,6 @@ function theme_user_signature($variables) {
 }
 
 /**
- * Get the language object preferred by the user. This user preference can
- * be set on the user account editing page, and is only available if there
- * are more than one languages enabled on the site. If the user did not
- * choose a preferred language, or is the anonymous user, the $default
- * value, or if it is not set, the site default language will be returned.
- *
- * @param $account
- *   User account to look up language for.
- * @param $type
- *   Optional string to define which preferred langcode should be used.
- *   Default to 'preferred_langcode' property.
- *   If set 'preferred_$type_langcode' is used.
- * @param $default
- *   Optional default language code to return if the account
- *   has no valid language.
- */
-function user_preferred_langcode($account, $type = NULL, $default = NULL) {
-  $language_list = language_list();
-  $account = $account->getBCEntity();
-  if (isset($type)) {
-    $preferred_langcode = $account->{'preferred_' . $type . '_langcode'};
-  }
-  else {
-    $preferred_langcode = $account->preferred_langcode;
-  }
-  if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) {
-    return $language_list[$preferred_langcode]->id;
-  }
-  else {
-    return $default ? $default : language_default()->id;
-  }
-}
-
-/**
  * Conditionally create and send a notification email when a certain
  * operation happens on the given user account.
  *
@@ -1993,7 +1945,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) {
   $notify = config('user.settings')->get('notify.' . $op);
   if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) {
     $params['account'] = $account;
-    $langcode = $langcode ? $langcode : user_preferred_langcode($account);
+    $langcode = $langcode ? $langcode : $account->getPreferredLangcode();
     // Get the custom site notification email to use as the from email address
     // if it has been set.
     $site_mail = config('system.site')->get('mail_notification');
@@ -2157,7 +2109,7 @@ function user_toolbar() {
   global $user;
 
   // Add logout & user account links or login link.
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     $links = array(
       'account' => array(
         'title' => t('View profile'),
@@ -2169,7 +2121,7 @@ function user_toolbar() {
       ),
       'account_edit' => array(
         'title' => t('Edit profile'),
-        'href' => 'user/' . $user->uid . '/edit',
+        'href' => 'user/' . $user->id() . '/edit',
         'html' => TRUE,
         'attributes' => array(
           'title' => t('Edit user account'),
@@ -2194,7 +2146,7 @@ function user_toolbar() {
     '#type' => 'toolbar_item',
     'tab' => array(
       '#type' => 'link',
-      '#title' => user_format_name($user),
+      '#title' => $user->getUsername(),
       '#href' => 'user',
       '#options' => array(
         'attributes' => array(
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index f5f164f..6077a27 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -19,10 +19,10 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
 
   // When processing the one-time login link, we have to make sure that a user
   // isn't already logged in.
-  if ($user->uid) {
+  if ($user->isAuthenticated()) {
     // The existing user is already logged in.
-    if ($user->uid == $uid) {
-      drupal_set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/$user->uid/edit"))));
+    if ($user->id() == $uid) {
+      drupal_set_message(t('You are logged in as %user. <a href="!user_edit">Change your password.</a>', array('%user' => $user->name, '!user_edit' => url("user/" . $user->id() . "/edit"))));
     }
     // A different user is already logged in on the computer.
     else {
@@ -49,7 +49,7 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
         drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
         return new RedirectResponse(url('user/password', array('absolute' => TRUE)));
       }
-      elseif ($account->uid && $timestamp >= $account->login && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
+      elseif ($account->isAuthenticated() && $timestamp >= $account->login && $timestamp <= $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
         // First stage is a confirmation form, then login
         if ($action == 'login') {
           // Set the new user.
@@ -60,8 +60,8 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a
           drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));
           // Let the user's password be changed without the current password check.
           $token = Crypt::randomStringHashed(55);
-          $_SESSION['pass_reset_' . $user->uid] = $token;
-          return new RedirectResponse(url('user/' . $user->uid . '/edit', array(
+          $_SESSION['pass_reset_' . $user->id()] = $token;
+          return new RedirectResponse(url('user/' . $user->id() . '/edit', array(
             'query' => array('pass-reset-token' => $token),
             'absolute' => TRUE,
           )));
@@ -129,7 +129,7 @@ function user_edit_cancel_submit($form, &$form_state) {
   }
   // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear.
   $account = $form_state['controller']->getEntity();
-  $form_state['redirect'] = array("user/" . $account->uid . "/cancel", array('query' => $destination));
+  $form_state['redirect'] = array("user/" . $account->id() . "/cancel", array('query' => $destination));
 }
 
 /**
@@ -148,7 +148,7 @@ function user_cancel_confirm_form($form, &$form_state, $account) {
   $can_select_method = $admin_access || user_access('select account cancellation method');
   $form['user_cancel_method'] = array(
     '#type' => 'radios',
-    '#title' => ($account->uid == $user->uid ? t('When cancelling your account') : t('When cancelling the account')),
+    '#title' => ($account->id() == $user->id() ? t('When cancelling your account') : t('When cancelling the account')),
     '#access' => $can_select_method,
   );
   $form['user_cancel_method'] += user_cancel_methods();
@@ -156,7 +156,7 @@ function user_cancel_confirm_form($form, &$form_state, $account) {
   // Allow user administrators to skip the account cancellation confirmation
   // mail (by default), as long as they do not attempt to cancel their own
   // account.
-  $override_access = $admin_access && ($account->uid != $user->uid);
+  $override_access = $admin_access && ($account->id() != $user->id());
   $form['user_cancel_confirm'] = array(
     '#type' => 'checkbox',
     '#title' => t('Require e-mail confirmation to cancel account.'),
@@ -175,7 +175,7 @@ function user_cancel_confirm_form($form, &$form_state, $account) {
   );
 
   // Prepare confirmation form page title and description.
-  if ($account->uid == $user->uid) {
+  if ($account->id() == $user->id()) {
     $question = t('Are you sure you want to cancel your account?');
   }
   else {
@@ -193,10 +193,10 @@ function user_cancel_confirm_form($form, &$form_state, $account) {
   }
 
   // Always provide entity id in the same form key as in the entity edit form.
-  $form['uid'] = array('#type' => 'value', '#value' => $account->uid);
+  $form['uid'] = array('#type' => 'value', '#value' => $account->id());
   return confirm_form($form,
     $question,
-    'user/' . $account->uid,
+    'user/' . $account->id(),
     $description . ' ' . t('This action cannot be undone.'),
     t('Cancel account'), t('Cancel'));
 }
@@ -214,8 +214,8 @@ function user_cancel_confirm_form_submit($form, &$form_state) {
   // Cancel account immediately, if the current user has administrative
   // privileges, no confirmation mail shall be sent, and the user does not
   // attempt to cancel the own account.
-  if (user_access('administer users') && empty($form_state['values']['user_cancel_confirm']) && $account->uid != $user->uid) {
-    user_cancel($form_state['values'], $account->uid, $form_state['values']['user_cancel_method']);
+  if (user_access('administer users') && empty($form_state['values']['user_cancel_confirm']) && $account->id() != $user->id()) {
+    user_cancel($form_state['values'], $account->id(), $form_state['values']['user_cancel_method']);
 
     $form_state['redirect'] = 'admin/people';
   }
@@ -229,7 +229,7 @@ function user_cancel_confirm_form_submit($form, &$form_state) {
     drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
     watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
 
-    $form_state['redirect'] = "user/$account->uid";
+    $form_state['redirect'] = "user/" . $account->id();
   }
 }
 
@@ -306,7 +306,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') {
   $account_data = drupal_container()->get('user.data')->get('user', $account->id());
   if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
     // Validate expiration and hashed password/login.
-    if ($timestamp <= $current && $current - $timestamp < $timeout && $account->uid && $timestamp >= $account->login && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
+    if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->login && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
       $edit = array(
         'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : config('user.settings')->get('notify.status_canceled'),
       );
@@ -318,7 +318,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') {
     }
     else {
       drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'));
-      return new RedirectResponse(url("user/$account->uid/cancel", array('absolute' => TRUE)));
+      return new RedirectResponse(url("user/" . $account->id() . "/cancel", array('absolute' => TRUE)));
     }
   }
   throw new AccessDeniedHttpException();
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 185ad6e..1f98006 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -83,7 +83,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
         // Basic user account information.
         case 'uid':
           // In the case of hook user_presave uid is not set yet.
-          $replacements[$original] = !empty($account->uid) ? $account->uid : t('not yet assigned');
+          $replacements[$original] = $account->id() ?: t('not yet assigned');
           break;
 
         case 'name':
@@ -96,11 +96,11 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
           break;
 
         case 'url':
-          $replacements[$original] = !empty($account->uid) ? url("user/$account->uid", $url_options) : t('not yet assigned');
+          $replacements[$original] = $account->id() ? url("user/" . $account->id(), $url_options) : t('not yet assigned');
           break;
 
         case 'edit-url':
-          $replacements[$original] = !empty($account->uid) ? url("user/$account->uid/edit", $url_options) : t('not yet assigned');
+          $replacements[$original] = $account->id() ? url("user/" . $account->id() . "/edit", $url_options) : t('not yet assigned');
           break;
 
         // These tokens are default variations on the chained tokens handled below.
@@ -125,7 +125,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
   }
 
   if ($type == 'current-user') {
-    $account = user_load($GLOBALS['user']->uid);
+    $account = user_load($GLOBALS['user']->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 371d112..622cdbf 100644
--- a/core/modules/user/user.views_execution.inc
+++ b/core/modules/user/user.views_execution.inc
@@ -14,5 +14,5 @@
  */
 function user_views_query_substitutions(ViewExecutable $view) {
   global $user;
-  return array('***CURRENT_USER***' => intval($user->uid));
+  return array('***CURRENT_USER***' => $user->id());
 }
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
index 62ed735..5dab9c7 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
@@ -286,7 +286,7 @@ public function generateResultsKey() {
       $key_data = array(
         'build_info' => $build_info,
         'roles' => $user->roles,
-        'super-user' => $user->uid == 1, // special caching for super user.
+        'super-user' => $user->id() == 1, // special caching for super user.
         'langcode' => language(Language::TYPE_INTERFACE)->id,
         'base_url' => $GLOBALS['base_url'],
       );
@@ -315,7 +315,7 @@ public function generateOutputKey() {
       $key_data = array(
         'result' => $this->view->result,
         'roles' => $user->roles,
-        'super-user' => $user->uid == 1, // special caching for super user.
+        'super-user' => $user->id() == 1, // special caching for super user.
         'theme' => $GLOBALS['theme'],
         'langcode' => language(Language::TYPE_INTERFACE)->id,
         'base_url' => $GLOBALS['base_url'],
diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
index 1fa8689..730b123 100644
--- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
@@ -100,7 +100,7 @@ protected function setUp() {
       search_index($node->nid, 'node', $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], Language::LANGCODE_NOT_SPECIFIED);
 
       $comment = array(
-        'uid' => $user->uid,
+        'uid' => $user->id(),
         'nid' => $node->nid,
         'node_type' => 'node_type_' . $node->bundle(),
       );
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php
index 92fa27b..e3538e6 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php
@@ -775,7 +775,7 @@ public function cacheSet() {
    *   TRUE if the view is locked, FALSE otherwise.
    */
   public function isLocked() {
-    return is_object($this->lock) && ($this->lock->owner != $GLOBALS['user']->uid);
+    return is_object($this->lock) && ($this->lock->owner != $GLOBALS['user']->id());
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
index a0ba259..97b6e23 100644
--- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
@@ -9,9 +9,9 @@
 
 use Drupal\Core\Access\AccessCheckInterface;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Session\UserSession;
 use Drupal\Tests\UnitTestCase;
 use Drupal\user\Access\RoleAccessCheck;
-use Drupal\user\Plugin\Core\Entity\User;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -108,25 +108,25 @@ public function roleAccessProvider() {
     // Setup one user with the first role, one with the second, one with both
     // and one final without any of these two roles.
 
-    $account_1 = (object) array(
+    $account_1 = new UserSession(array(
       'uid' => 1,
       'roles' => array($rid_1),
-    );
+    ));
 
-    $account_2 = (object) array(
+    $account_2 = new UserSession(array(
       'uid' => 2,
       'roles' => array($rid_2),
-    );
+    ));
 
-    $account_12 = (object) array(
+    $account_12 = new UserSession(array(
       'uid' => 3,
       'roles' => array($rid_1, $rid_2),
-    );
+    ));
 
-    $account_none = (object) array(
+    $account_none = new UserSession(array(
       'uid' => 1,
       'roles' => array(),
-    );
+    ));
 
     // Setup expected values; specify which paths can be accessed by which user.
     return array(
@@ -169,7 +169,7 @@ public function testRoleAccess($path, $grant_accounts, $deny_accounts) {
     foreach ($deny_accounts as $account) {
       $subrequest = Request::create($path, 'GET');
       $subrequest->attributes->set('account', $account);
-      $message = sprintf('Access denied for user %s with the roles %s on path: %s', $account->uid, implode(', ', $account->roles), $path);
+      $message = sprintf('Access denied for user %s with the roles %s on path: %s', $account->id(), implode(', ', $account->roles), $path);
       $has_access = $role_access_check->access($collection->get($path), $subrequest);
       $this->assertSame(AccessCheckInterface::DENY, $has_access , $message);
     }
diff --git a/core/update.php b/core/update.php
index b74e226..fba6b86 100644
--- a/core/update.php
+++ b/core/update.php
@@ -354,7 +354,7 @@ function update_access_allowed() {
     return user_access('administer software updates');
   }
   catch (\Exception $e) {
-    return ($user->uid == 1);
+    return ($user->id() == 1);
   }
 }
 
