summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2013-07-11 17:29:02 (GMT)
committer Dries2013-07-11 17:29:02 (GMT)
commitc02ba600876cd4658c7711bd070cf0adf4f8f125 (patch)
tree1519edcb40fb8e2fbf89bb812e516ab6db8be111
parent5feff937faf0d98dbe2eed72d085f95bcfeed884 (diff)
Issue #2039199 by Berdir: Convert ->uid to ->id(), isAnonymous() and isAuthenticated().
-rw-r--r--core/includes/bootstrap.inc4
-rw-r--r--core/includes/common.inc4
-rw-r--r--core/includes/file.inc2
-rw-r--r--core/includes/form.inc8
-rw-r--r--core/includes/language.inc2
-rw-r--r--core/includes/session.inc12
-rw-r--r--core/includes/theme.inc2
-rw-r--r--core/lib/Drupal/Core/Entity/Field/Field.php4
-rw-r--r--core/lib/Drupal/Core/Session/UserSession.php2
-rw-r--r--core/modules/block/block.module2
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockTest.php2
-rw-r--r--core/modules/comment/comment.module18
-rw-r--r--core/modules/comment/lib/Drupal/comment/CommentAccessController.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/CommentFormController.php20
-rw-r--r--core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php4
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php8
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php2
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php4
-rw-r--r--core/modules/contact/contact.module8
-rw-r--r--core/modules/contact/lib/Drupal/contact/MessageFormController.php8
-rw-r--r--core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php28
-rw-r--r--core/modules/content_translation/content_translation.module2
-rw-r--r--core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php2
-rw-r--r--core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php2
-rw-r--r--core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php2
-rw-r--r--core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php8
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/field/widget/AutocompleteWidgetBase.php2
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php18
-rw-r--r--core/modules/file/file.module6
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php4
-rw-r--r--core/modules/filter/filter.module8
-rw-r--r--core/modules/forum/forum.module10
-rw-r--r--core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php2
-rw-r--r--core/modules/history/history.module10
-rw-r--r--core/modules/history/lib/Drupal/history/Plugin/views/field/HistoryUserTimestamp.php6
-rw-r--r--core/modules/history/lib/Drupal/history/Plugin/views/filter/HistoryUserTimestamp.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php4
-rw-r--r--core/modules/node/lib/Drupal/node/NodeFormController.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php10
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAccessTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php10
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/PageEditTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php2
-rw-r--r--core/modules/node/node.admin.inc2
-rw-r--r--core/modules/node/node.api.php6
-rw-r--r--core/modules/node/node.module32
-rw-r--r--core/modules/node/node.pages.inc4
-rw-r--r--core/modules/node/tests/modules/node_access_test/node_access_test.module4
-rw-r--r--core/modules/overlay/lib/Drupal/overlay/EventSubscriber/OverlaySubscriber.php2
-rw-r--r--core/modules/overlay/overlay.module6
-rw-r--r--core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php2
-rw-r--r--core/modules/php/lib/Drupal/php/Plugin/Filter/Php.php2
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php10
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Tests/StandardProfileTest.php2
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Tests/UserAttributesTest.php6
-rw-r--r--core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php2
-rw-r--r--core/modules/shortcut/lib/Drupal/shortcut/ShortcutStorageController.php6
-rw-r--r--core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php10
-rw-r--r--core/modules/shortcut/shortcut.admin.inc8
-rw-r--r--core/modules/shortcut/shortcut.module10
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php10
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php2
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php2
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php2
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Datetime/DrupalDateTimeTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php8
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php16
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityRevisionsTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php5
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php30
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php22
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/MainContentFallbackTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/SiteMaintenanceTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Update/UpdateScriptTest.php2
-rw-r--r--core/modules/system/system.api.php8
-rw-r--r--core/modules/system/system.module10
-rw-r--r--core/modules/system/tests/modules/database_test/database_test.module11
-rw-r--r--core/modules/system/tests/modules/form_test/form_test.module2
-rw-r--r--core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessor.php2
-rw-r--r--core/modules/system/tests/modules/url_alter_test/lib/Drupal/url_alter_test/PathProcessorTest.php2
-rw-r--r--core/modules/toolbar/toolbar.module2
-rw-r--r--core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php4
-rw-r--r--core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php14
-rw-r--r--core/modules/tracker/tracker.module2
-rw-r--r--core/modules/tracker/tracker.pages.inc2
-rw-r--r--core/modules/translation/translation.module2
-rw-r--r--core/modules/user/lib/Drupal/user/Access/LoginStatusCheck.php2
-rw-r--r--core/modules/user/lib/Drupal/user/AccountFormController.php14
-rw-r--r--core/modules/user/lib/Drupal/user/Controller/UserController.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php2
-rw-r--r--core/modules/user/lib/Drupal/user/ProfileFormController.php2
-rw-r--r--core/modules/user/lib/Drupal/user/RegisterFormController.php8
-rw-r--r--core/modules/user/lib/Drupal/user/TempStoreFactory.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserAdminTest.php18
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserBlocksTests.php10
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php84
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserDeleteTest.php10
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserEditTest.php20
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php6
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php6
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php10
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserTimeZoneTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php10
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserValidateCurrentPassCustomFormTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php6
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php4
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php2
-rw-r--r--core/modules/user/user.admin.inc12
-rw-r--r--core/modules/user/user.api.php20
-rw-r--r--core/modules/user/user.install4
-rw-r--r--core/modules/user/user.pages.inc34
-rw-r--r--core/modules/user/user.tokens.inc8
-rw-r--r--core/modules/user/user.views_execution.inc2
-rw-r--r--core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php4
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php2
-rw-r--r--core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php20
-rw-r--r--core/update.php2
165 files changed, 504 insertions, 502 deletions
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index bae9d9e..f7ab2d7 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 4829751..dfd20fa 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3069,7 +3069,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)));
}
/**
@@ -4163,7 +4163,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 c8e71ae..2a2de1f 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 004ad92..0ff36d7 100644
--- a/core/lib/Drupal/Core/Entity/Field/Field.php
+++ b/core/lib/Drupal/Core/Entity/Field/Field.php
@@ -172,8 +172,8 @@ class Field extends ItemList implements FieldInterface {
*/
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/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php
index 41d55fc..b3dae61 100644
--- a/core/lib/Drupal/Core/Session/UserSession.php
+++ b/core/lib/Drupal/Core/Session/UserSession.php
@@ -19,7 +19,7 @@ class UserSession implements AccountInterface {
*
* @var int
*/
- public $uid;
+ protected $uid;
/**
* Session hostname.
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 10b4c73..cfbad28 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -289,7 +289,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 1bceb3a..7f7855d 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 @@ class BlockTest extends BlockTestBase {
$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 8ba44d1..f436966 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)) {
@@ -1613,7 +1613,7 @@ function template_preprocess_comment(&$variables) {
if ($comment->uid->target_id == $variables['node']->uid) {
$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 @@ class CommentAccessController extends EntityAccessController {
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 @@ class CommentFormController extends EntityFormControllerNG {
$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 @@ class CommentFormController extends EntityFormControllerNG {
$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 @@ class CommentFormController extends EntityFormControllerNG {
'#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 @@ class CommentFormController extends EntityFormControllerNG {
$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 @@ class CommentFormController extends EntityFormControllerNG {
'#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 @@ class CommentFormController extends EntityFormControllerNG {
'#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 @@ class CommentFormController extends EntityFormControllerNG {
// 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 @@ class CommentFormController extends EntityFormControllerNG {
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 @@ class CommentFormController extends EntityFormControllerNG {
// @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 @@ class Comment extends EntityNG implements CommentInterface {
}
// 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 @@ class NodeNewComments extends Numeric {
public function preRender(&$values) {
global $user;
- if (!$user->uid || empty($values)) {
+ if ($user->isAnonymous() || empty($values)) {
return;
}
@@ -114,7 +114,7 @@ class NodeNewComments extends Numeric {
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 @@ class CommentCSSTest extends CommentTestBase {
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 @@ class CommentCSSTest extends CommentTestBase {
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 @@ class CommentInterfaceTest extends CommentTestBase {
// 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 @@ class CommentLanguageTest extends WebTestBase {
// 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 @@ class CommentNewIndicatorTest extends CommentTestBase {
'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 @@ class CommentPreviewTest extends CommentTestBase {
$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 @@ class CommentStatisticsTest extends CommentTestBase {
$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 @@ class CommentStatisticsTest extends CommentTestBase {
// 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 @@ class CommentStatisticsTest extends CommentTestBase {
// 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 @@ abstract class CommentTestBase extends WebTestBase {
));
// 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 @@ class CommentThreadingTest extends CommentTestBase {
// 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 @@ class ArgumentUserUIDTest extends CommentTestBase {
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 @@ abstract class CommentTestBase extends ViewTestBase {
$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 @@ class FilterUserUIDTest extends CommentTestBase {
'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 6390aba..a4abbac 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -44,7 +44,7 @@ class MessageFormController extends EntityFormControllerNG {
'#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 @@ class MessageFormController extends EntityFormControllerNG {
'#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 @@ class MessageFormController extends EntityFormControllerNG {
$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();
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 @@ class ContactPersonalTest extends WebTestBase {
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 @@ class ContactPersonalTest extends WebTestBase {
// 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 @@ class ContactPersonalTest extends WebTestBase {
// 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 @@ class ContactPersonalTest extends WebTestBase {
$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 @@ class ContactPersonalTest extends WebTestBase {
}
// 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 @@ class ContactPersonalTest extends WebTestBase {
'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 @@ class ContentTranslationController implements ContentTranslationControllerInterf
// @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 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
// 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 a206f1b..1e21d53 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 @@ abstract class ContentTranslationUITest extends ContentTranslationTestBase {
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/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 @@ class DbLogTest extends WebTestBase {
'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 @@ class DbLogTest extends WebTestBase {
// 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 @@ class DbLogTest extends WebTestBase {
$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 @@ class DbLogTest extends WebTestBase {
'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 @@ abstract class AutocompleteWidgetBase extends WidgetBase {
'#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 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
'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 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
'result' => array(
'user' => array(
- $users['non_admin']->uid => $user_labels['non_admin'],
+ $users['non_admin']->id() => $user_labels['non_admin'],
),
),
),
@@ -311,10 +311,10 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
'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 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
'result' => array(
'user' => array(
- $users['blocked']->uid => $user_labels['blocked'],
+ $users['blocked']->id() => $user_labels['blocked'],
),
),
),
@@ -335,7 +335,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
'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 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$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 @@ class FileFieldRevisionTest extends FileFieldTestBase {
$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 495f245..1a0d9d1 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -275,16 +275,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 1c9b89d..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'));
@@ -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 @@ class ForumTest extends WebTestBase {
$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 @@ class HistoryUserTimestamp extends Node {
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 @@ class HistoryUserTimestamp extends Node {
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 @@ class HistoryUserTimestamp extends Node {
// 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 @@ class HistoryUserTimestamp extends FilterPluginBase {
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/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 @@ class DeleteMultiple extends ConfirmFormBase implements ControllerInterface {
* {@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 @@ class DeleteMultiple extends ConfirmFormBase implements ControllerInterface {
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 e55e0566..814d937 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -47,7 +47,7 @@ class NodeFormController extends EntityFormController {
}
}
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 186bb3e..9b839d0 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php
@@ -62,7 +62,7 @@ class DeleteNode extends ActionBase implements ContainerFactoryPluginInterface {
* {@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 @@ class NodeAccessBaseTableTest extends NodeTestBase {
$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 @@ class NodeAccessBaseTableTest extends NodeTestBase {
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 @@ class NodeAccessBaseTableTest extends NodeTestBase {
'%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 @@ class NodeAccessBaseTableTest extends NodeTestBase {
// 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..66448d0 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 @@ class NodeAccessTest extends NodeTestBase {
// 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.
@@ -56,7 +56,7 @@ class NodeAccessTest extends NodeTestBase {
// User can 'view own unpublished content', but another user cannot.
$web_user4 = $this->drupalCreateUser(array('access content', 'view own unpublished content'));
$web_user5 = $this->drupalCreateUser(array('access content', 'view own unpublished content'));
- $node4 = $this->drupalCreateNode(array('status' => 0, 'uid' => $web_user4->uid));
+ $node4 = $this->drupalCreateNode(array('status' => 0, 'uid' => $web_user4->id()));
$this->assertNodeAccess(array('view' => TRUE, 'update' => FALSE), $node4, $web_user4);
$this->assertNodeAccess(array('view' => FALSE), $node4, $web_user5);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
index 6ad8a19..73d8a3b 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
@@ -96,8 +96,8 @@ class NodeAdminTest extends NodeTestBase {
$nodes['published_page'] = $this->drupalCreateNode(array('type' => 'page'));
$nodes['published_article'] = $this->drupalCreateNode(array('type' => 'article'));
- $nodes['unpublished_page_1'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_1->uid, 'status' => 0));
- $nodes['unpublished_page_2'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_2->uid, 'status' => 0));
+ $nodes['unpublished_page_1'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_1->id(), 'status' => 0));
+ $nodes['unpublished_page_2'] = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->base_user_2->id(), 'status' => 0));
// Verify view, edit, and delete links for any content.
$this->drupalGet('admin/content');
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 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$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 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$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 @@ class NodeCreationTest extends NodeTestBase {
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 @@ class NodeQueryAlterTest extends NodeTestBase {
// $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 @@ class NodeSaveTest extends NodeTestBase {
$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 @@ class NodeSaveTest extends NodeTestBase {
$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 @@ class NodeSaveTest extends NodeTestBase {
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 @@ class NodeSaveTest extends NodeTestBase {
// 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 @@ class NodeSaveTest extends NodeTestBase {
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 @@ class NodeTokenReplaceTest extends NodeTestBase {
$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 @@ class NodeTranslationUITest extends ContentTranslationUITest {
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 @@ class PageEditTest extends NodeTestBase {
// 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 @@ class PageEditTest extends NodeTestBase {
$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/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php
index 375bd32..67b4cba 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php
@@ -55,7 +55,7 @@ class FilterUidRevisionTest extends NodeTestBase {
$view = views_get_view('test_filter_node_uid_revision');
$view->initHandlers();
- $view->filter['uid_revision']->value = array($author->uid);
+ $view->filter['uid_revision']->value = array($author->id());
$this->executeView($view);
$this->assertIdenticalResultset($view, $expected_result, array('nid' => 'nid'), 'Make sure that the view only returns nodes which match either the node or the revision author.');
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 7afef9f..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')
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index bb67b20..a3e0138 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 7878a5f..e836700 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])) {
@@ -1015,7 +1015,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);
@@ -1027,14 +1027,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;
}
@@ -1049,12 +1049,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);
}
@@ -1425,7 +1425,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')
@@ -2135,7 +2135,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 Drupal::entityManager()->getAccessController('node')->access($node, $op, $langcode, $account);
@@ -2154,13 +2154,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;
}
}
@@ -2299,21 +2299,21 @@ 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 {
- $access[$account->uid] = Drupal::entityManager()->getAccessController('node')->checkAllGrants($account);
+ $access[$account->id()] = Drupal::entityManager()->getAccessController('node')->checkAllGrants($account);
}
- 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 6a668ab..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
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 @@ use Drupal\Core\Entity\EntityInterface;
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 @@ class OverlaySubscriber implements EventSubscriberInterface {
// 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 0a316e5..3e6f989 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -230,11 +230,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',
@@ -243,7 +243,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 @@ class PathLanguageTest extends PathTestBase {
// 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 @@ class Php extends FilterBase {
$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 @@ class CommentAttributesTest extends CommentTestBase {
*/
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 @@ class CommentAttributesTest extends CommentTestBase {
*/
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 @@ class CommentAttributesTest extends CommentTestBase {
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 f1e4fb1..8abf538 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 @@ class StandardProfileTest extends WebTestBase {
$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 @@ class UserAttributesTest extends WebTestBase {
$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/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 @@ class EntitySerializationTest extends NormalizerTestBase {
// 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 @@ class ShortcutStorageController extends ConfigStorageController implements Short
*/
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 @@ class ShortcutStorageController extends ConfigStorageController implements Short
*/
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 @@ class ShortcutStorageController extends ConfigStorageController implements Short
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 @@ class ShortcutSetsTest extends ShortcutTestBase {
$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 @@ class ShortcutSetsTest extends ShortcutTestBase {
// 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 @@ class ShortcutSetsTest extends ShortcutTestBase {
'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 @@ class ShortcutSetsTest extends ShortcutTestBase {
*/
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 @@ class ShortcutSetsTest extends ShortcutTestBase {
$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 3ee8e0b..30530af 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 6923f69..dd094a1 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;
}
}
@@ -206,7 +206,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;
@@ -327,8 +327,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.
@@ -343,7 +343,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 7b927da..f0aa5fd 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -269,11 +269,11 @@ abstract class WebTestBase extends TestBase {
// 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();
}
}
@@ -487,8 +487,8 @@ abstract class WebTestBase extends TestBase {
$account = entity_create('user', $edit);
$account->save();
- $this->assertTrue(!empty($account->uid), String::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
- if (empty($account->uid)) {
+ $this->assertTrue($account->id(), String::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
+ if (!$account->id()) {
return FALSE;
}
@@ -610,7 +610,7 @@ abstract class WebTestBase extends TestBase {
* $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 @@ class StatisticsAdminTest extends WebTestBase {
}
$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 @@ class StatisticsLoggingTest extends WebTestBase {
$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 @@ class StatisticsReportsTest extends StatisticsTestBase {
$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 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
// 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 6c0d23a..b46f751 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -121,13 +121,13 @@ class FormatDateTest extends WebTestBase {
$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 @@ class DrupalDateTimeTest extends WebTestBase {
// 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 @@ class EntityApiTest extends EntityUnitTestBase {
*/
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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
$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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
'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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
));
$_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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
));
$_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 7bc9107..0781716 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 @@ class EntityFieldTest extends EntityUnitTestBase {
// 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 @@ class EntityFieldTest extends EntityUnitTestBase {
$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 @@ class EntityFieldTest extends EntityUnitTestBase {
$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 @@ class EntityFieldTest extends EntityUnitTestBase {
'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 @@ class EntityFieldTest extends EntityUnitTestBase {
$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 @@ class EntityQueryRelationshipTest extends EntityUnitTestBase {
$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 @@ class EntityRevisionsTest extends WebTestBase {
// 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 d9e464f..40a7e44 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 @@ class EntityTranslationTest extends EntityUnitTestBase {
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 @@ class EntityValidationTest extends EntityUnitTestBase {
// 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/Form/FormCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
index aa94a68..07e3992 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
+use Drupal\Core\Session\UserSession;
use Drupal\simpletest\DrupalUnitTestBase;
/**
@@ -45,7 +46,7 @@ class FormCacheTest extends DrupalUnitTestBase {
* Tests the form cache with a logged-in user.
*/
function testCacheToken() {
- $GLOBALS['user']->uid = 1;
+ $GLOBALS['user'] = new UserSession(array('uid' => 1));
form_set_cache($this->form_build_id, $this->form, $this->form_state);
$cached_form_state = form_state_defaults();
@@ -74,7 +75,7 @@ class FormCacheTest extends DrupalUnitTestBase {
* Tests the form cache without a logged-in user.
*/
function testNoCacheToken() {
- $GLOBALS['user']->uid = 0;
+ $GLOBALS['user'] = new UserSession(array('uid' => 0));
$this->form_state['example'] = $this->randomName();
form_set_cache($this->form_build_id, $this->form, $this->form_state);
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 @@ class BreadcrumbTest extends MenuTestBase {
// 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 @@ class BreadcrumbTest extends MenuTestBase {
// 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 @@ class BreadcrumbTest extends MenuTestBase {
$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 @@ class BreadcrumbTest extends MenuTestBase {
$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 @@ class BreadcrumbTest extends MenuTestBase {
$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 @@ class MenuRouterTest extends WebTestBase {
$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 @@ class UpcastingTest extends WebTestBase {
$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 @@ class UrlAlterFunctionalTest extends WebTestBase {
$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 @@ class SessionHttpsTest extends WebTestBase {
$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 @@ class SessionTest extends WebTestBase {
$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 @@ class SessionTest extends WebTestBase {
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 @@ class SessionTest extends WebTestBase {
// 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 @@ class SessionTest extends WebTestBase {
// 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 @@ class SessionTest extends WebTestBase {
$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 @@ class SessionTest extends WebTestBase {
// 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 @@ class SessionTest extends WebTestBase {
);
$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 @@ class SessionTest extends WebTestBase {
// 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 5ad1676..eb4ba4a 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 @@ class AccessDeniedTest extends WebTestBase {
// 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 @@ class MainContentFallbackTest extends WebTestBase {
// 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 @@ class PageNotFoundTest extends WebTestBase {
// 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 @@ class SiteMaintenanceTest extends WebTestBase {
);
$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 @@ class TokenReplaceTest extends WebTestBase {
// 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 @@ class UpdateScriptTest extends WebTestBase {
$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/system.api.php b/core/modules/system/system.api.php
index 3fe115e..ac57121 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -2160,7 +2160,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;
}
@@ -2631,11 +2631,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']);
@@ -3059,7 +3059,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 96e08dc..ac42ea3 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;
@@ -2427,7 +2427,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')))));
}
}
@@ -2446,11 +2446,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..8772662 100644
--- a/core/modules/system/tests/modules/database_test/database_test.module
+++ b/core/modules/system/tests/modules/database_test/database_test.module
@@ -221,18 +221,19 @@ function database_test_theme_tablesort($form, &$form_state) {
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('Drupal\Core\Database\Query\TableSortExtender');
$query
- ->fields('u', array('uid', 'name', 'status', 'created', 'access'))
+ ->fields('u', array('uid'))
->limit(50)
->orderByHeader($header)
->setCountQuery($count_query);
- $result = $query->execute();
+ $uids = $query
+ ->execute()
+ ->fetchCol();
$options = array();
$status = array(t('blocked'), t('active'));
- $accounts = array();
- foreach ($result as $account) {
- $options[$account->uid] = array(
+ foreach (user_load_multiple($uids) as $account) {
+ $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 @@ class PathProcessor implements InboundPathProcessorInterface {
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 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
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 23fd4b5..26520c6 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -630,7 +630,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 @@ class TrackerNodeAccessTest extends WebTestBase {
$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 @@ class TrackerNodeAccessTest extends WebTestBase {
$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 @@ class TrackerTest extends WebTestBase {
$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 @@ class TrackerTest extends WebTestBase {
);
$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 @@ class TrackerTest extends WebTestBase {
$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 @@ class TrackerTest extends WebTestBase {
$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 529e97e..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
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/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 @@ class LoginStatusCheck implements AccessCheckInterface {
* {@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 94250a0..950c341 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -24,7 +24,7 @@ abstract class AccountFormController extends EntityFormController {
$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 @@ abstract class AccountFormController extends EntityFormController {
'#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 @@ abstract class AccountFormController extends EntityFormController {
// 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 @@ abstract class AccountFormController extends EntityFormController {
}
// 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,
@@ -259,7 +259,7 @@ abstract class AccountFormController extends EntityFormController {
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 @@ abstract class AccountFormController extends EntityFormController {
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 @@ abstract class AccountFormController extends EntityFormController {
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/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php
index 185a16f..8e623d1 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 @@ class UserPasswordForm implements FormInterface, ControllerInterface {
),
);
// 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 @@ class UserPasswordForm implements FormInterface, ControllerInterface {
$users = $this->userStorageController->loadByProperties(array('name' => $name, 'status' => '1'));
}
$account = reset($users);
- if (isset($account->uid)) {
+ if ($account && $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 2c5c742..009cb5b 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
@@ -62,7 +62,7 @@ class CancelUser extends ActionBase implements ContainerFactoryPluginInterface {
* {@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 0d5c711..ab4401c 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 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
* 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/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index ee8d818..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
@@ -108,7 +108,7 @@ class User extends EntityNG implements UserInterface {
// 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();
}
}
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 @@ class User extends ArgumentDefaultPluginBase {
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 52aaad6..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 @@ class User extends ArgumentValidatorPluginBase {
// 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
@@ -159,7 +159,7 @@ class User extends ArgumentValidatorPluginBase {
}
}
- $this->argument->argument = $account->uid;
+ $this->argument->argument = $account->id();
$this->argument->validated_title = check_plain(user_format_name($account));
return TRUE;
}
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 @@ class Name extends User {
$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 @@ class Name extends InOperator {
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 @@ class ProfileFormController extends AccountFormController {
$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 @@ class RegisterFormController extends AccountFormController {
);
// 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 @@ class RegisterFormController extends AccountFormController {
$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 @@ class TempStoreFactory {
// 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 @@ class UserAdminTest extends WebTestBase {
$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 @@ class UserAdminTest extends WebTestBase {
$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 @@ class UserAdminTest extends WebTestBase {
$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 @@ class UserBlocksTests extends WebTestBase {
$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 @@ class UserBlocksTests extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserDeleteTest extends WebTestBase {
$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 @@ class UserDeleteTest extends WebTestBase {
$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 @@ class UserDeleteTest extends WebTestBase {
->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 @@ class UserEditTest extends WebTestBase {
// 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 @@ class UserEditTest extends WebTestBase {
$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 @@ class UserEditTest extends WebTestBase {
// 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 @@ class UserEditedOwnAccountTest extends WebTestBase {
// 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 @@ class UserEntityCallbacksTest extends WebTestBase {
*/
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 @@ class UserLanguageCreationTest extends WebTestBase {
// 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 @@ class UserLanguageTest extends WebTestBase {
// 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 @@ class UserLoginTest extends WebTestBase {
$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 @@ class UserLoginTest extends WebTestBase {
$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 abddd20..f01c14e 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 @@ class UserPasswordResetTest extends WebTestBase {
// 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 @@ class UserPasswordResetTest extends WebTestBase {
$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 @@ class UserPasswordResetTest extends WebTestBase {
// 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 @@ class UserPictureTest extends WebTestBase {
// 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 @@ class UserPictureTest extends WebTestBase {
*/
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 @@ class UserRolesAssignmentTest extends WebTestBase {
$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 @@ class UserRolesAssignmentTest extends WebTestBase {
// 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 @@ class UserRolesAssignmentTest extends WebTestBase {
* 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 @@ class UserSignatureTest extends WebTestBase {
$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 894555e..c4ff9ff 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 @@ class UserTimeZoneTest extends WebTestBase {
$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 @@ class UserTokenReplaceTest extends WebTestBase {
$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 @@ class UserValidateCurrentPassCustomFormTest extends WebTestBase {
$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 @@ class ArgumentDefaultTest extends UserTestBase {
$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 @@ class ArgumentValidateTest extends UserTestBase {
$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 @@ class ArgumentValidateTest extends UserTestBase {
// 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 @@ class ArgumentValidateTest extends UserTestBase {
// 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 @@ class HandlerArgumentUserUidTest extends UserTestBase {
// 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 @@ class HandlerFilterUserNameTest extends ViewTestBase {
$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 @@ class RelationshipRepresentativeNode extends UserTestBase {
$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 @@ abstract class UserTestBase extends ViewTestBase {
$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/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.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 @@ use Drupal\views\ViewExecutable;
*/
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 @@ abstract class CachePluginBase extends PluginBase {
$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 @@ abstract class CachePluginBase extends PluginBase {
$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 @@ class DefaultViewsTest extends ViewTestBase {
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 @@ class ViewUI implements ViewStorageInterface {
* 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 @@ namespace Drupal\Tests\Core\Route;
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 @@ class RoleAccessCheckTest extends UnitTestCase {
// 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 @@ class RoleAccessCheckTest extends UnitTestCase {
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);
}
}