diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 2adc576..bcd1db2 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1779,7 +1779,7 @@ function install_finished(&$install_state) { // Load current user and perform final login tasks. // This has to be done after drupal_flush_all_caches() // to avoid session regeneration. - $account = user_load(1); + $account = user::load(1); user_login_finalize($account); } diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php index bb7fb91..43eae9a 100644 --- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php +++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php @@ -55,7 +55,7 @@ protected function setUp() { */ public function testContactLink() { $accounts = array(); - $accounts['root'] = user_load(1); + $accounts['root'] = user::load(1); // Create an account with access to all contact pages. $admin_account = $this->drupalCreateUser(array('administer users')); $accounts['admin'] = $admin_account; diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index b1b6e9b..cd9ec27 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -251,7 +251,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En $name = \Drupal::currentUser()->getUsername(); } elseif ($entity->translation[$form_langcode]['uid']) { - $name = user_load($entity->translation[$form_langcode]['uid'])->getUsername(); + $name = user::load($entity->translation[$form_langcode]['uid'])->getUsername(); } $form['content_translation']['name'] = array( '#type' => 'textfield', diff --git a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php index b37666e..8d5eaf3 100644 --- a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php +++ b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php @@ -41,12 +41,12 @@ protected function setUp() { parent::setUp(); // Assign user 1 a language code so that the entity can be translated. - $user = user_load(1); + $user = user::load(1); $user->langcode = 'en'; $user->save(); // Assign user 2 LANGCODE_NOT_SPECIFIED code so entity can't be translated. - $user = user_load(2); + $user = user::load(2); $user->langcode = Language::LANGCODE_NOT_SPECIFIED; $user->save(); diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php index 2ef2d06..1fd3efe 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -186,7 +186,7 @@ public function overview() { } $username = array( '#theme' => 'username', - '#account' => user_load($dblog->uid), + '#account' => user::load($dblog->uid), ); $rows[] = array( 'data' => array( @@ -237,7 +237,7 @@ public function eventDetails($event_id) { $message = $this->formatMessage($dblog); $username = array( '#theme' => 'username', - '#account' => user_load($dblog->uid), + '#account' => user::load($dblog->uid), ); $rows = array( array( diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php index a6edb35..8906e9f 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php @@ -224,8 +224,8 @@ public function testUserHandler() { // Build a set of test data. $user_values = array( - 'anonymous' => user_load(0), - 'admin' => user_load(1), + 'anonymous' => user::load(0), + 'admin' => user::load(1), 'non_admin' => array( 'name' => 'non_admin <&>', 'mail' => 'non_admin@example.com', diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 6b99955..37117ef 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -689,7 +689,7 @@ function template_preprocess_forum_icon(&$variables) { function template_preprocess_forum_submitted(&$variables) { $variables['author'] = ''; if (isset($variables['topic']->uid)) { - $username = array('#theme' => 'username', '#account' => user_load($variables['topic']->uid)); + $username = array('#theme' => 'username', '#account' => user::load($variables['topic']->uid)); $variables['author'] = drupal_render($username); } $variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $variables['topic']->created) : ''; diff --git a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6User.php b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6User.php index d30c697..f196709 100644 --- a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6User.php +++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6User.php @@ -169,7 +169,7 @@ protected static function getSchema() { 'type' => 'text', 'not null' => FALSE, 'size' => 'big', - 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.', + 'description' => 'A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user::load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.', ), // Field not part of Drupal 6 schema. Added by Date contributed module. 'timezone_name' => array( diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 33461c9..80ed68f 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -174,7 +174,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr // Default values for the chained tokens handled below. case 'author': - $account = $node->getOwner() ? $node->getOwner() : user_load(0); + $account = $node->getOwner() ? $node->getOwner() : user::load(0); $replacements[$original] = $sanitize ? String::checkPlain($account->label()) : $account->label(); break; diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php index f73ac3b..f49ce4d 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -86,7 +86,7 @@ protected function setUp() { // Load the user 1 user for later use as an admin user with permission to // see everything. - $this->admin_user = user_load(1); + $this->admin_user = user::load(1); // The node_access_test_language module allows individual translations of a // node to be marked private (not viewable by normal users), and the diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php index ad82dea..552d258 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php @@ -73,7 +73,7 @@ protected function setUp() { // Load the user 1 user for later use as an admin user with permission to // see everything. - $this->admin_user = user_load(1); + $this->admin_user = user::load(1); // Add Hungarian and Catalan. ConfigurableLanguage::createFromLangcode('hu')->save(); diff --git a/core/modules/node/src/Tests/NodeAccessLanguageTest.php b/core/modules/node/src/Tests/NodeAccessLanguageTest.php index c97dc07..0bed04b 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php @@ -225,7 +225,7 @@ function testNodeAccessQueryTag() { // Load the user 1 user for later use as an admin user with permission to // see everything. - $admin_user = user_load(1); + $admin_user = user::load(1); // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. diff --git a/core/modules/rest/src/Tests/DeleteTest.php b/core/modules/rest/src/Tests/DeleteTest.php index 6456df1..61f1d07 100644 --- a/core/modules/rest/src/Tests/DeleteTest.php +++ b/core/modules/rest/src/Tests/DeleteTest.php @@ -71,7 +71,9 @@ public function testDelete() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $this->httpRequest('entity/user/' . $account->id(), 'DELETE'); - $user = entity_load('user', $account->id(), TRUE); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + $user_storage->resetCache(array($account->id())); + $user = User::load($account->id()); $this->assertEqual($account->id(), $user->id(), 'User still exists in the database.'); $this->assertResponse(404); } diff --git a/core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php b/core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php index a3f3a64..9bf34f8 100644 --- a/core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php +++ b/core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php @@ -97,7 +97,7 @@ public function testDateTimezone() { \Drupal::service('session_manager')->disable(); // Save the original user and then replace it with the test user. $real_user = $user; - $user = user_load($test_user->id(), 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/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php index 537697f..7505cdc 100644 --- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php @@ -501,7 +501,7 @@ public function testUserHooks() { )); $GLOBALS['entity_crud_hook_test'] = array(); - user_load($account->id()); + user::load($account->id()); $this->assertHookMessageOrder(array( 'entity_crud_hook_test_entity_load called for type user', diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 4e98a64..701cbe8 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -814,7 +814,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr // Default values for the chained tokens handled below. case 'author': - $account = $node->getOwner() ? $node->getOwner() : user_load(0); + $account = $node->getOwner() ? $node->getOwner() : user::load(0); $replacements[$original] = $sanitize ? String::checkPlain($account->label()) : $account->label(); break; diff --git a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php index 644dd49..bd08bc8 100644 --- a/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php +++ b/core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php @@ -45,7 +45,7 @@ public function processInbound($path, Request $request) { public function processOutbound($path, &$options = array(), Request $request = NULL) { // Rewrite user/uid to user/username. if (preg_match('!^user/([0-9]+)(/.*)?!', $path, $matches)) { - if ($account = user_load($matches[1])) { + if ($account = user::load($matches[1])) { $matches += array(2 => ''); $path = 'user/' . $account->getUsername() . $matches[2]; } diff --git a/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php b/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php index 3820628..c56ae5b 100644 --- a/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php +++ b/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php @@ -124,7 +124,7 @@ public function entityQueryAlter(SelectInterface $query) { $value_part->condition('anonymous_name', $condition['value'], $condition['operator']); $value_part->compile(Database::getConnection(), $query); $or->condition(db_and() - ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name(user_load(0)))) + ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name(user::load(0)))) ->condition('base_table.uid', 0) ); $query->condition($or); diff --git a/core/modules/user/src/Tests/UserAdminListingTest.php b/core/modules/user/src/Tests/UserAdminListingTest.php index bf4681e..e51da60 100644 --- a/core/modules/user/src/Tests/UserAdminListingTest.php +++ b/core/modules/user/src/Tests/UserAdminListingTest.php @@ -57,7 +57,7 @@ public function testUserListing() { $admin_user = $this->drupalCreateUser(array('administer users')); $accounts[$admin_user->label()] = $admin_user; - $accounts['admin'] = entity_load('user', 1); + $accounts['admin'] = User::load(1); $this->drupalLogin($admin_user); diff --git a/core/modules/user/src/Tests/UserAdminTest.php b/core/modules/user/src/Tests/UserAdminTest.php index 900090c..6a16ab0 100644 --- a/core/modules/user/src/Tests/UserAdminTest.php +++ b/core/modules/user/src/Tests/UserAdminTest.php @@ -93,7 +93,7 @@ function testUserAdmin() { $this->assertText($user_c->getUsername(), 'User C on filtered by role on admin users page'); // Test blocking of a user. - $account = user_load($user_c->id()); + $account = user::load($user_c->id()); $this->assertTrue($account->isActive(), 'User C not blocked'); $edit = array(); $edit['action'] = 'user_block_user_action'; @@ -103,7 +103,7 @@ function testUserAdmin() { // targeted with the blocking action. 'query' => array('order' => 'name', 'sort' => 'asc') )); - $account = user_load($user_c->id(), TRUE); + $account = user::load($user_c->id(), TRUE); $this->assertTrue($account->isBlocked(), 'User C blocked'); // Test filtering on admin page for blocked users @@ -121,18 +121,18 @@ function testUserAdmin() { // targeted with the blocking action. 'query' => array('order' => 'name', 'sort' => 'asc') )); - $account = user_load($user_c->id(), TRUE); + $account = user::load($user_c->id(), TRUE); $this->assertTrue($account->isActive(), 'User C unblocked'); $this->assertMail("to", $account->getEmail(), "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->id(), TRUE); + $account1 = user::load($user_d->id(), TRUE); $this->drupalPostForm('user/' . $account1->id() . '/edit', array('status' => 0), t('Save')); - $account1 = user_load($user_d->id(), TRUE); + $account1 = user::load($user_d->id(), TRUE); $this->assertTrue($account1->isBlocked(), 'User D blocked'); $this->drupalPostForm('user/' . $account1->id() . '/edit', array('status' => TRUE), t('Save')); - $account1 = user_load($user_d->id(), TRUE); + $account1 = user::load($user_d->id(), TRUE); $this->assertTrue($account1->isActive(), 'User D unblocked'); $this->assertMail("to", $account1->getEmail(), "Activation mail sent to user D"); } diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php index 6a191da..09503ed 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -42,7 +42,7 @@ function testUserCancelWithoutPermission() { $account = $this->drupalCreateUser(array()); $this->drupalLogin($account); // Load real user object. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); // Create a node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -55,7 +55,7 @@ function testUserCancelWithoutPermission() { $timestamp = $account->getLastLoginTime(); $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); $this->assertResponse(403, 'Bogus cancelling request rejected.'); - $account = user_load($account->id()); + $account = user::load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Confirm user's content has not been altered. @@ -86,7 +86,7 @@ function testUserCancelUid1() { ->execute(); // Reload and log in uid 1. - $user1 = user_load(1, TRUE); + $user1 = user::load(1, TRUE); $user1->pass_raw = $password; // Try to cancel uid 1's account with a different user. @@ -99,7 +99,7 @@ function testUserCancelUid1() { $this->drupalPostForm('admin/people', $edit, t('Apply')); // Verify that uid 1's account was not cancelled. - $user1 = user_load(1, TRUE); + $user1 = user::load(1, TRUE); $this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.'); } @@ -114,7 +114,7 @@ function testUserCancelInvalid() { $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); // Load real user object. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); // Create a node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -131,14 +131,14 @@ function testUserCancelInvalid() { $bogus_timestamp = $timestamp + 60; $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->getPassword(), $bogus_timestamp, $account->getLastLoginTime())); $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->id()); + $account = user::load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Attempt expired account cancellation request confirmation. $bogus_timestamp = $timestamp - 86400 - 60; $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->getPassword(), $bogus_timestamp, $account->getLastLoginTime())); $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->id(), TRUE); + $account = user::load($account->id(), TRUE); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Confirm user's content has not been altered. @@ -158,7 +158,7 @@ function testUserBlock() { $this->drupalLogin($web_user); // Load real user object. - $account = user_load($web_user->id(), TRUE); + $account = user::load($web_user->id(), TRUE); // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); @@ -175,7 +175,7 @@ function testUserBlock() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); // Confirm that the confirmation message made it through to the end user. @@ -195,7 +195,7 @@ function testUserBlockUnpublish() { $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); // Load real user object. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); // Create a node with two revisions. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -230,7 +230,7 @@ function testUserBlockUnpublish() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); // Confirm user's content has been unpublished. @@ -260,7 +260,7 @@ function testUserAnonymize() { $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); // Load real user object. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); // Create a simple node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -287,7 +287,7 @@ function testUserAnonymize() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); - $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); + $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. $node_storage->resetCache(array($node->id())); @@ -317,7 +317,7 @@ function testUserDelete() { $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'skip comment approval')); $this->drupalLogin($account); // Load real user object. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); // Create a simple node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -356,7 +356,7 @@ function testUserDelete() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())); - $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); + $this->assertFalse(user::load($account->id(), TRUE), 'User is not found in the database.'); // Confirm that user's content has been deleted. $node_storage->resetCache(array($node->id())); @@ -393,7 +393,7 @@ function testUserCancelByAdmin() { // Confirm deletion. $this->drupalPostForm(NULL, NULL, t('Cancel account')); $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), 'User deleted.'); - $this->assertFalse(user_load($account->id()), 'User is not found in the database.'); + $this->assertFalse(user::load($account->id()), 'User is not found in the database.'); } /** @@ -421,7 +421,7 @@ function testUserWithoutEmailCancelByAdmin() { // Confirm deletion. $this->drupalPostForm(NULL, NULL, t('Cancel account')); $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), 'User deleted.'); - $this->assertFalse(user_load($account->id()), 'User is not found in the database.'); + $this->assertFalse(user::load($account->id()), 'User is not found in the database.'); } /** @@ -461,17 +461,17 @@ function testMassUserCancelByAdmin() { $status = TRUE; foreach ($users as $account) { $status = $status && (strpos($this->content, t('%name has been deleted.', array('%name' => $account->getUsername()))) !== FALSE); - $status = $status && !user_load($account->id(), 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 email address.'), 'Account cancellation request mailed message displayed.'); - $admin_user = user_load($admin_user->id()); + $admin_user = user::load($admin_user->id()); $this->assertTrue($admin_user->isActive(), 'Administrative user is found in the database and enabled.'); // Verify that uid 1's account was not cancelled. - $user1 = user_load(1, TRUE); + $user1 = user::load(1, TRUE); $this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.'); } } diff --git a/core/modules/user/src/Tests/UserDeleteTest.php b/core/modules/user/src/Tests/UserDeleteTest.php index 747039e..1481069 100644 --- a/core/modules/user/src/Tests/UserDeleteTest.php +++ b/core/modules/user/src/Tests/UserDeleteTest.php @@ -38,7 +38,7 @@ function testUserDeleteMultiple() { $this->assertTrue($roles_created > 0, 'Role assigments created for new users and deletion of role assigments can be tested'); // We should be able to load one of the users. - $this->assertTrue(user_load($user_a->id()), '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. @@ -51,8 +51,8 @@ function testUserDeleteMultiple() { ->fetchField(); $this->assertTrue($roles_after_deletion == 0, 'Role assigments deleted along with users'); // Test if the users are deleted, user_load() will return FALSE. - $this->assertFalse(user_load($user_a->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()))); + $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/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php index 0e80ba5..cc49bee 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -120,7 +120,7 @@ function testPasswordRehashOnLogin() { $this->drupalLogin($account); $this->drupalLogout(); // Load the stored user. The password hash should reflect $default_count_log2. - $account = user_load($account->id()); + $account = user::load($account->id()); $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $default_count_log2); // Change the required number of iterations by loading a test-module @@ -133,7 +133,7 @@ function testPasswordRehashOnLogin() { $account->pass_raw = $password; $this->drupalLogin($account); // Load the stored user, which should have a different password hash now. - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); $this->assertIdentical($password_hasher->getCountLog2($account->getPassword()), $overridden_count_log2); } diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/src/Tests/UserPasswordResetTest.php index e69cfa8..e68460c 100644 --- a/core/modules/user/src/Tests/UserPasswordResetTest.php +++ b/core/modules/user/src/Tests/UserPasswordResetTest.php @@ -43,7 +43,7 @@ protected function setUp() { // Activate user by logging in. $this->drupalLogin($account); - $this->account = user_load($account->id()); + $this->account = user::load($account->id()); $this->drupalLogout(); // Set the last login time that is used to generate the one-time link so diff --git a/core/modules/user/src/Tests/UserPictureTest.php b/core/modules/user/src/Tests/UserPictureTest.php index 639c382..0b7a2a5 100644 --- a/core/modules/user/src/Tests/UserPictureTest.php +++ b/core/modules/user/src/Tests/UserPictureTest.php @@ -133,7 +133,7 @@ function saveUserPicture($image) { $this->drupalPostForm('user/' . $this->web_user->id() . '/edit', $edit, t('Save')); // Load actual user data from database. - $account = user_load($this->web_user->id(), TRUE); + $account = user::load($this->web_user->id(), TRUE); return file_load($account->user_picture->target_id, TRUE); } } diff --git a/core/modules/user/src/Tests/UserRolesAssignmentTest.php b/core/modules/user/src/Tests/UserRolesAssignmentTest.php index 124a263..110323a 100644 --- a/core/modules/user/src/Tests/UserRolesAssignmentTest.php +++ b/core/modules/user/src/Tests/UserRolesAssignmentTest.php @@ -86,7 +86,7 @@ function testCreateUserWithRole() { * Defaults to TRUE. */ private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) { - $account = user_load($account->id(), TRUE); + $account = user::load($account->id(), TRUE); if ($is_assigned) { $this->assertTrue(array_search($rid, $account->getRoles()), 'The role is present in the user object.'); } diff --git a/core/modules/user/src/Tests/UserSaveTest.php b/core/modules/user/src/Tests/UserSaveTest.php index fdd468c..cdfe5cf 100644 --- a/core/modules/user/src/Tests/UserSaveTest.php +++ b/core/modules/user/src/Tests/UserSaveTest.php @@ -37,7 +37,7 @@ function testUserImport() { $user->save(); // Test if created user exists. - $user_by_uid = user_load($test_uid); + $user_by_uid = user::load($test_uid); $this->assertTrue($user_by_uid, 'Loading user by uid.'); $user_by_name = user_load_by_name($test_name); diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index 897e2aa..60feb53 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -49,8 +49,8 @@ function testUserTokenReplacement() { $this->drupalLogout(); $this->drupalLogin($user2); - $account = user_load($user1->id()); - $global_account = user_load(\Drupal::currentUser()->id()); + $account = user::load($user1->id()); + $global_account = user::load(\Drupal::currentUser()->id()); // Generate and test sanitized tokens. $tests = array(); diff --git a/core/modules/user/src/Tests/Views/BulkFormTest.php b/core/modules/user/src/Tests/Views/BulkFormTest.php index 2bf721b..46d91f9 100644 --- a/core/modules/user/src/Tests/Views/BulkFormTest.php +++ b/core/modules/user/src/Tests/Views/BulkFormTest.php @@ -45,7 +45,7 @@ public function testBulkForm() { $this->assertText(t('No users selected.')); // Assign a role to a user. - $account = entity_load('user', $this->users[0]->id()); + $account = User::load($this->users[0]->id()); $roles = user_role_names(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); $role = key($roles); @@ -57,7 +57,8 @@ public function testBulkForm() { ); $this->drupalPostForm(NULL, $edit, t('Apply')); // Re-load the user and check their roles. - $account = entity_load('user', $account->id(), TRUE); + $user_storage->resetCache(array($account->id())); + $account = User::load($account->id()); $this->assertTrue($account->hasRole($role), 'The user now has the custom role.'); $edit = array( @@ -66,7 +67,8 @@ public function testBulkForm() { ); $this->drupalPostForm(NULL, $edit, t('Apply')); // Re-load the user and check their roles. - $account = entity_load('user', $account->id(), TRUE); + $user_storage->resetCache(array($account->id())); + $account = User::load($account->id()); $this->assertFalse($account->hasRole($role), 'The user no longer has the custom role.'); // Block a user using the bulk form. @@ -78,7 +80,8 @@ public function testBulkForm() { ); $this->drupalPostForm(NULL, $edit, t('Apply')); // Re-load the user and check their status. - $account = entity_load('user', $account->id(), TRUE); + $user_storage->resetCache(array($account->id())); + $account = User::load($account->id()); $this->assertTrue($account->isBlocked(), 'The user is blocked.'); $this->assertNoRaw($account->label(), 'The user is not found in the table.'); @@ -97,7 +100,7 @@ public function testBulkForm() { 'action' => 'user_block_user_action', ); $this->drupalPostForm(NULL, $edit, t('Apply')); - $anonymous_account = user_load(0); + $anonymous_account = user::load(0); $this->assertTrue($anonymous_account->isBlocked(), 'Ensure the anonymous user got blocked.'); // Test the list of available actions with a value that contains a dot. diff --git a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php index 6612ec4..70a13ba 100644 --- a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php @@ -36,7 +36,7 @@ public function testRole() { $this->drupalCreateRole(array('access content'), $rolename_not_assigned, $rolename_not_assigned); // Add roles to user 1. - $user = entity_load('user', 1); + $user = User::load(1); $user->addRole($rolename_a); $user->addRole($rolename_b); $user->save(); diff --git a/core/modules/user/src/Tests/Views/UserTestBase.php b/core/modules/user/src/Tests/Views/UserTestBase.php index 51017dc..9a7f985 100644 --- a/core/modules/user/src/Tests/Views/UserTestBase.php +++ b/core/modules/user/src/Tests/Views/UserTestBase.php @@ -42,7 +42,7 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('user_test_views')); $this->users[] = $this->drupalCreateUser(); - $this->users[] = user_load(1); + $this->users[] = user::load(1); $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->id())); $this->nodes[] = $this->drupalCreateNode(array('uid' => 1)); } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index bc0e15c..18ce76f 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -148,7 +148,7 @@ function user_attach_accounts(array &$build, array $entities) { $uids[] = $entity->getOwnerId(); } $uids = array_unique($uids); - $accounts = user_load_multiple($uids); + $accounts = User::loadMultiple($uids); $anonymous = entity_create('user', array('uid' => 0)); foreach ($entities as $id => $entity) { @@ -766,7 +766,7 @@ function user_pass_rehash($password, $timestamp, $login) { * @see _user_cancel() */ function user_cancel($edit, $uid, $method) { - $account = user_load($uid); + $account = user::load($uid); if (!$account) { drupal_set_message(t('The user account %id does not exist.', array('%id' => $uid)), 'error'); diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index 073b90f..762db2f 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -127,7 +127,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr } if ($type == 'current-user') { - $account = user_load(\Drupal::currentUser()->id()); + $account = user::load(\Drupal::currentUser()->id()); $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options); } diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh index 9925fe1..6f6eee4 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -161,7 +161,7 @@ module_load_include('inc', 'node', 'node.pages'); for ($i = 0; $i < 36; $i++) { $uid = intval($i / 8) + 3; - $user = user_load($uid); + $user = user::load($uid); $node = new stdClass(); $node->uid = $uid; $node->type = 'page'; @@ -206,7 +206,7 @@ $node->path = array('alias' => "content/$node->created"); node_save($node); if ($node->revision) { - $user = user_load($uid + 3); + $user = user::load($uid + 3); ++$revision_id; $node->title .= " rev2 $revision_id"; $body_text = str_repeat("node revision body ($node->type) - $i", 100); @@ -227,7 +227,7 @@ // Create poll content for ($i = 0; $i < 12; $i++) { $uid = intval($i / 4) + 3; - $user = user_load($uid); + $user = user::load($uid); $node = new stdClass(); $node->uid = $uid; $node->type = 'poll'; @@ -272,7 +272,7 @@ $uid = 6; $node_type = 'broken'; -$user = user_load($uid); +$user = user::load($uid); $node = new stdClass(); $node->uid = $uid; $node->type = 'article';