diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 9b947caffa5d4c4d0558debc6c69d48aacac3c8e..d858875e3d80c4836fa339261309e9e828f8b069 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -26,7 +26,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Route; - +use Drupal\user\Entity\User; use GuzzleHttp\Exception\RequestException; /** @@ -1851,7 +1851,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/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index 6d3b4a257fb556f22b35c779355714be443263cb..11427bafd817854e2c746aaaac2f6089bf056cef 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -40,7 +40,7 @@ * // Load a node and a user, then replace tokens in the text. * $text = 'On [date:short], [user:name] read [node:title].'; * $node = Node::load(1); - * $user = user_load(1); + * $user = User::load(1); * * // [date:...] tokens use the current date automatically. * $data = array('node' => $node, 'user' => $user); diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php index bb7fb91b43ff4e602f6a123d8018523509afaeaf..320deb073b5204f6a48c2e91f953a696a0139efd 100644 --- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php +++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php @@ -9,6 +9,7 @@ use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; +use Drupal\user\Entity\User; /** * Tests the contact link field. @@ -55,7 +56,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/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php index b37666e874b5251fca8f4a2260ce90d1f2ac8bc7..485f6f54beca828ada800ee364eed6eb053eea1b 100644 --- a/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php +++ b/core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php @@ -11,6 +11,7 @@ use Drupal\content_translation\Tests\ContentTranslationTestBase; use Drupal\views\Tests\ViewTestData; use Drupal\Core\Language\Language; +use Drupal\user\Entity\User; /** * Tests the content translation overview link field handler. @@ -41,12 +42,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 d6dcfabcd68bbeb158942e26e7dbfe87bb6c8c6f..b896be20e325f9d9a9b23f0c24a4b2c0f1e0ca47 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -53,6 +53,13 @@ class DbLogController extends ControllerBase { */ protected $formBuilder; + /** + * The user storage. + * + * @var \Drupal\user\UserStorageInterface + */ + protected $userStorage; + /** * {@inheritdoc} */ @@ -82,6 +89,7 @@ public function __construct(Connection $database, ModuleHandlerInterface $module $this->moduleHandler = $module_handler; $this->dateFormatter = $date_formatter; $this->formBuilder = $form_builder; + $this->userStorage = $this->entityManager()->getStorage('user'); } /** @@ -188,7 +196,7 @@ public function overview() { } $username = array( '#theme' => 'username', - '#account' => user_load($dblog->uid), + '#account' => $this->userStorage->load($dblog->uid), ); $rows[] = array( 'data' => array( @@ -239,7 +247,7 @@ public function eventDetails($event_id) { $message = $this->formatMessage($dblog); $username = array( '#theme' => 'username', - '#account' => user_load($dblog->uid), + '#account' => $this->userStorage->load($dblog->uid), ); $rows = array( array( diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 4ddc77591680c5c13ed92cf78eb285ea48429380..026967e796c4d12ac3e2b3efeb6a358b7feec394 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -16,6 +16,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\taxonomy\Entity\Vocabulary; use Symfony\Component\Routing\Exception\RouteNotFoundException; +use Drupal\user\Entity\User; /** * Implements hook_help(). @@ -629,7 +630,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/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 4f4b06645d20a88ed917c8691d717ee5b91db1fb..7f8d50a85017a7069814716106815986b8a7c9d0 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -7,6 +7,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Language\LanguageInterface; +use Drupal\user\Entity\User; /** * Implements hook_token_info(). @@ -174,7 +175,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 ? SafeMarkup::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 1fedcb569829d539aa2f26050ec2b56d6138fa88..62a7b0c6f7443cfd2cc082d7c356a73b1e7933ac 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; +use Drupal\user\Entity\User; /** * Tests node access functionality with multiple languages and two node access @@ -86,7 +87,7 @@ protected function setUp() { // Load the user 1 user for later use as an admin user with permission to // see everything. - $this->adminUser = user_load(1); + $this->adminUser = 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 a9ee922dd460e6c5f7f0783f10427970d48d1c2c..135161711ad1fa9e6b1c11d5b8ad378ad86af93c 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\Entity\ConfigurableLanguage; +use Drupal\user\Entity\User; /** * Tests node_access and db_select() with node_access tag functionality with @@ -79,7 +80,7 @@ protected function setUp() { // Load the user 1 user for later use as an admin user with permission to // see everything. - $this->adminUser = user_load(1); + $this->adminUser = 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 6345007e9fe21059b50029f3ef287d6a7181a21a..949c385bd577b8e757dbcfed3d111a3657eb3ff1 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; +use Drupal\user\Entity\User; /** * Tests node_access and db_select() with node_access tag functionality with @@ -226,7 +227,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 5a86d776ad577986aef3a9a055e7966a9fccb5ff..f205f3024edbf57b5f784d06b58de97ec663f289 100644 --- a/core/modules/rest/src/Tests/DeleteTest.php +++ b/core/modules/rest/src/Tests/DeleteTest.php @@ -8,7 +8,6 @@ namespace Drupal\rest\Tests; use Drupal\Core\Url; -use Drupal\rest\Tests\RESTTestBase; /** * Tests the deletion of resources. @@ -72,7 +71,9 @@ public function testDelete() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); $this->httpRequest($account->urlInfo(), '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_storage->load($account->id()); $this->assertEqual($account->id(), $user->id(), 'User still exists in the database.'); $this->assertResponse(405); } diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index 6cba2e0eabdf0bc04ee8ccf011148a2b3a55c7ee..d3bf74fba996ff4e154454a473a1512bf74e47af 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -678,7 +678,7 @@ protected function checkPermissions(array $permissions) { * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw; - * $account = user_load($account->id()); + * $account = User::load($account->id()); * $account->passRaw = $pass_raw; * @endcode * diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index de206583affb3886feed93f9f0ae3b6273b97f9a..29874118a9b62fff0aa2e6db426c267693f1d80d 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -672,7 +672,7 @@ protected function checkPermissions(array $permissions) { * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->pass_raw; - * $account = user_load($account->id()); + * $account = User::load($account->id()); * $account->pass_raw = $pass_raw; * @endcode * diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php index deff706fb20a48ba8fac2428bb07597b5a21d9eb..0e62fcef31ed762bb9f71a11c91dd58b36487c8b 100644 --- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php @@ -16,6 +16,7 @@ use Drupal\taxonomy\Entity\Term; use Drupal\node\Entity\Node; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\user\Entity\User; /** * Tests the invocation of hooks when creating, inserting, loading, updating or @@ -504,7 +505,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/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php index 358c883964947a6ee2042211d48649191b65b10b..45e0e923b1ef66f79964075d0641b1160a3d6d11 100644 --- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php +++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php @@ -12,6 +12,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\comment\CommentInterface; use Drupal\simpletest\WebTestBase; +use Drupal\user\Entity\User; /** * Tests for the base handlers provided by Entity Reference. @@ -209,8 +210,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/system/tests/modules/database_test/src/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php index c44871a40a8053c7f43eb220e08bbf4d562b4ce0..342151e2295301c9eb93f68cd5f403adffb94bf6 100644 --- a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php +++ b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\user\Entity\User; /** * Form controller for database_test module. @@ -53,7 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $options = array(); - foreach (user_load_multiple($uids) as $account) { + foreach (User::loadMultiple($uids) as $account) { $options[$account->id()] = array( 'title' => array('data' => array('#title' => SafeMarkup::checkPlain($account->getUsername()))), 'username' => SafeMarkup::checkPlain($account->getUsername()), 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 644dd49e3e45bc845201c10b0da17238673360ee..c4b80176e0fe2e061839638def49baf393883e43 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 @@ -10,6 +10,7 @@ use Drupal\Core\PathProcessor\InboundPathProcessorInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Symfony\Component\HttpFoundation\Request; +use Drupal\user\Entity\User; /** * Path processor for url_alter_test. @@ -45,7 +46,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/system/token.api.php b/core/modules/system/token.api.php index ed7c74c1e5381770406cc2846be62ddb7531b5fd..51133de50d0673bd5ce35c0a7b64457eea098201 100644 --- a/core/modules/system/token.api.php +++ b/core/modules/system/token.api.php @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\SafeMarkup; +use Drupal\user\Entity\User; /** * @addtogroup hooks @@ -84,7 +85,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 ? SafeMarkup::checkPlain($account->label()) : $account->label(); break; diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php index d766378aa34ed7fc50d4ca0680772ed10c8e8bce..e2dd03d3fb04c1c5fefba7474a7f890b194167ec 100644 --- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php +++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php @@ -37,6 +37,13 @@ class UserSelection extends SelectionBase { */ protected $connection; + /** + * The user storage. + * + * @var \Drupal\user\UserStorageInterface + */ + protected $userStorage; + /** * Constructs a new UserSelection object. * @@ -59,6 +66,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user); $this->connection = $connection; + $this->userStorage = $entity_manager->getStorage('user'); } /** @@ -194,7 +202,7 @@ public function entityQueryAlter(SelectInterface $query) { $value_part->condition('anonymous_name', $condition['value'], $condition['operator']); $value_part->compile($this->connection, $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($this->userStorage->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 bf4681e887d54873018e20b55e440e7e8b124692..fbf31976288e87035d50458e05235c0d488759b2 100644 --- a/core/modules/user/src/Tests/UserAdminListingTest.php +++ b/core/modules/user/src/Tests/UserAdminListingTest.php @@ -8,6 +8,7 @@ namespace Drupal\user\Tests; use Drupal\simpletest\WebTestBase; +use Drupal\user\Entity\User; /** * Tests the user admin listing if views is not enabled. @@ -57,7 +58,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 06b5f72c61a659df31eabe1bb203a19eab037cdf..691839d540ec2c8bec179ed8ab9a96ee06e116b0 100644 --- a/core/modules/user/src/Tests/UserAdminTest.php +++ b/core/modules/user/src/Tests/UserAdminTest.php @@ -39,6 +39,8 @@ function testUserAdmin() { $user_c->name = 'User C'; $user_c->save(); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + // Create admin user to delete registered user. $admin_user = $this->drupalCreateUser(array('administer users')); // Use a predictable name so that we can reliably order the user admin page @@ -94,7 +96,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_storage->load($user_c->id()); $this->assertTrue($account->isActive(), 'User C not blocked'); $edit = array(); $edit['action'] = 'user_block_user_action'; @@ -104,7 +106,8 @@ function testUserAdmin() { // targeted with the blocking action. 'query' => array('order' => 'name', 'sort' => 'asc') )); - $account = user_load($user_c->id(), TRUE); + $user_storage->resetCache(array($user_c->id())); + $account = $user_storage->load($user_c->id()); $this->assertTrue($account->isBlocked(), 'User C blocked'); // Test filtering on admin page for blocked users @@ -122,18 +125,22 @@ function testUserAdmin() { // targeted with the blocking action. 'query' => array('order' => 'name', 'sort' => 'asc') )); - $account = user_load($user_c->id(), TRUE); + $user_storage->resetCache(array($user_c->id())); + $account = $user_storage->load($user_c->id()); $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); + $user_storage->resetCache(array($user_d->id())); + $account1 = $user_storage->load($user_d->id()); $this->drupalPostForm('user/' . $account1->id() . '/edit', array('status' => 0), t('Save')); - $account1 = user_load($user_d->id(), TRUE); + $user_storage->resetCache(array($user_d->id())); + $account1 = $user_storage->load($user_d->id()); $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); + $user_storage->resetCache(array($user_d->id())); + $account1 = $user_storage->load($user_d->id()); $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 92e7ce0d096d21c8f6f6888a359534a0cb134733..2d4939721375bc81add34ae57bf19114a64ac8c5 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -41,12 +41,14 @@ protected function setUp() { function testUserCancelWithoutPermission() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $account = $this->drupalCreateUser(array()); $this->drupalLogin($account); - // Load real user object. - $account = user_load($account->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); // Create a node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -59,7 +61,8 @@ function testUserCancelWithoutPermission() { $timestamp = $account->getLastLoginTime(); $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime(), $account->id())); $this->assertResponse(403, 'Bogus cancelling request rejected.'); - $account = user_load($account->id()); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Confirm user's content has not been altered. @@ -87,7 +90,7 @@ public function testUserCancelChangePermission() { // Confirm deletion. $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.'); } /** @@ -97,6 +100,8 @@ public function testUserCancelChangePermission() { * administer the site. */ function testUserCancelUid1() { + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + \Drupal::service('module_installer')->install(array('views')); \Drupal::service('router.builder')->rebuild(); // Update uid 1's name and password to we know it. @@ -113,7 +118,8 @@ function testUserCancelUid1() { ->execute(); // Reload and log in uid 1. - $user1 = user_load(1, TRUE); + $user_storage->resetCache(array(1)); + $user1 = $user_storage->load(1); $user1->pass_raw = $password; // Try to cancel uid 1's account with a different user. @@ -126,7 +132,8 @@ function testUserCancelUid1() { $this->drupalPostForm('admin/people', $edit, t('Apply')); // Verify that uid 1's account was not cancelled. - $user1 = user_load(1, TRUE); + $user_storage->resetCache(array(1)); + $user1 = $user_storage->load(1); $this->assertTrue($user1->isActive(), 'User #1 still exists and is not blocked.'); } @@ -136,12 +143,14 @@ function testUserCancelUid1() { function testUserCancelInvalid() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); - // Load real user object. - $account = user_load($account->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); // Create a node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -158,14 +167,16 @@ function testUserCancelInvalid() { $bogus_timestamp = $timestamp + 60; $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->getPassword(), $bogus_timestamp, $account->getLastLoginTime(), $account->id())); $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()); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->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(), $account->id())); $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); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); // Confirm user's content has not been altered. @@ -179,13 +190,15 @@ function testUserCancelInvalid() { */ function testUserBlock() { $this->config('user.settings')->set('cancel_method', 'user_cancel_block')->save(); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $web_user = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($web_user); - // Load real user object. - $account = user_load($web_user->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($web_user->id())); + $account = $user_storage->load($web_user->id()); // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); @@ -202,7 +215,8 @@ function testUserBlock() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime(), $account->id())); - $account = user_load($account->id(), TRUE); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); // Confirm that the confirmation message made it through to the end user. @@ -217,12 +231,14 @@ function testUserBlockUnpublish() { $this->config('user.settings')->set('cancel_method', 'user_cancel_block_unpublish')->save(); // Create comment field on page. $this->addDefaultCommentField('node', 'page'); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); - // Load real user object. - $account = user_load($account->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); // Create a node with two revisions. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -257,7 +273,8 @@ function testUserBlockUnpublish() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime(), $account->id())); - $account = user_load($account->id(), TRUE); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); $this->assertTrue($account->isBlocked(), 'User has been blocked.'); // Confirm user's content has been unpublished. @@ -284,12 +301,14 @@ function testUserAnonymize() { $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); // Create comment field on page. $this->addDefaultCommentField('node', 'page'); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $account = $this->drupalCreateUser(array('cancel account')); $this->drupalLogin($account); - // Load real user object. - $account = user_load($account->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); // Create a simple node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -330,7 +349,8 @@ function testUserAnonymize() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime(), $account->id())); - $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); + $user_storage->resetCache(array($account->id())); + $this->assertFalse($user_storage->load($account->id()), 'User is not found in the database.'); // Confirm that user's content has been attributed to anonymous user. $anonymous_user = User::getAnonymousUser(); @@ -362,12 +382,14 @@ function testUserDelete() { \Drupal::service('module_installer')->install(array('comment')); $this->resetAll(); $this->addDefaultCommentField('node', 'page'); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create a user. $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'skip comment approval')); $this->drupalLogin($account); - // Load real user object. - $account = user_load($account->id(), TRUE); + // Load a real user object. + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); // Create a simple node. $node = $this->drupalCreateNode(array('uid' => $account->id())); @@ -406,7 +428,8 @@ function testUserDelete() { // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime(), $account->id())); - $this->assertFalse(user_load($account->id(), TRUE), 'User is not found in the database.'); + $user_storage->resetCache(array($account->id())); + $this->assertFalse($user_storage->load($account->id()), 'User is not found in the database.'); // Confirm that user's content has been deleted. $node_storage->resetCache(array($node->id())); @@ -443,7 +466,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.'); } /** @@ -471,7 +494,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.'); } /** @@ -481,6 +504,7 @@ function testMassUserCancelByAdmin() { \Drupal::service('module_installer')->install(array('views')); \Drupal::service('router.builder')->rebuild(); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save(); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Enable account cancellation notification. $this->config('user.settings')->set('notify.status_canceled', TRUE)->save(); @@ -512,17 +536,20 @@ 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); + $user_storage->resetCache(array($account->id())); + $status = $status && !$user_storage->load($account->id()); } $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_storage->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); + $user_storage->resetCache(array(1)); + $user1 = $user_storage->load(1); $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 1c913115ba6206b112594ce3fd1aa99e229d9965..656373da415e81c090739b4134ab56ebb2e9b193 100644 --- a/core/modules/user/src/Tests/UserDeleteTest.php +++ b/core/modules/user/src/Tests/UserDeleteTest.php @@ -8,6 +8,7 @@ namespace Drupal\user\Tests; use Drupal\simpletest\WebTestBase; +use Drupal\user\Entity\User; /** * Tests account deleting of users. @@ -38,7 +39,7 @@ function testUserDeleteMultiple() { $this->assertTrue($roles_created > 0, 'Role assignments created for new users and deletion of role assignments can be tested'); // We should be able to load one of the users. - $this->assertTrue(user_load($user_a->id()), 'User is created and deletion 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. @@ -50,9 +51,9 @@ function testUserDeleteMultiple() { ->execute() ->fetchField(); $this->assertTrue($roles_after_deletion == 0, 'Role assignments 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()))); + // Test if the users are deleted, User::load() will return NULL. + $this->assertNull(User::load($user_a->id()), format_string('User with id @uid deleted.', array('@uid' => $user_a->id()))); + $this->assertNull(User::load($user_b->id()), format_string('User with id @uid deleted.', array('@uid' => $user_b->id()))); + $this->assertNull(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 27ffa2aafa3f25afb363efcd8bbb8759ec228985..31bcc327d72a3d877084ef738ba50b044499eef3 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -9,6 +9,7 @@ use Drupal\simpletest\WebTestBase; use Drupal\Core\Password\PhpassHashedPassword; +use Drupal\user\Entity\User; /** * Ensure that login works as expected. @@ -126,7 +127,8 @@ function testPasswordRehashOnLogin() { $this->drupalLogin($account); $this->drupalLogout(); // Load the stored user. The password hash should reflect $default_count_log2. - $account = user_load($account->id()); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + $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 @@ -139,7 +141,8 @@ 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); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); $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 c48199a9d9c5d57e8ed31488d5e85b4a23489955..90bdee8ce7500303844ffeba0349b50275decb88 100644 --- a/core/modules/user/src/Tests/UserPasswordResetTest.php +++ b/core/modules/user/src/Tests/UserPasswordResetTest.php @@ -56,7 +56,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 2938e6733721f60619851fae580ce78282f04553..4f70d441d36dbe1d4f12c986955a19e56431a85d 100644 --- a/core/modules/user/src/Tests/UserPictureTest.php +++ b/core/modules/user/src/Tests/UserPictureTest.php @@ -7,7 +7,6 @@ namespace Drupal\user\Tests; -use Drupal\Core\Cache\Cache; use Drupal\simpletest\WebTestBase; /** @@ -131,7 +130,9 @@ function saveUserPicture($image) { $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save')); // Load actual user data from database. - $account = user_load($this->webUser->id(), TRUE); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + $user_storage->resetCache(array($this->webUser->id())); + $account = $user_storage->load($this->webUser->id()); 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 79addc2d7472c334ab180f568f7f724bffc396fd..8e164f5a62526ba7183ca2048772c911ea3ac7c4 100644 --- a/core/modules/user/src/Tests/UserRolesAssignmentTest.php +++ b/core/modules/user/src/Tests/UserRolesAssignmentTest.php @@ -85,7 +85,9 @@ function testCreateUserWithRole() { * Defaults to TRUE. */ private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) { - $account = user_load($account->id(), TRUE); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); + $user_storage->resetCache(array($account->id())); + $account = $user_storage->load($account->id()); if ($is_assigned) { $this->assertFalse(array_search($rid, $account->getRoles()) === FALSE, '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 a2eaf5db5df1dd1f0706c416956f807575f74d39..528ef8d80dbbb10d571d6d1f493313cb9c67ae4b 100644 --- a/core/modules/user/src/Tests/UserSaveTest.php +++ b/core/modules/user/src/Tests/UserSaveTest.php @@ -8,6 +8,7 @@ namespace Drupal\user\Tests; use Drupal\simpletest\WebTestBase; +use Drupal\user\Entity\User; /** * Tests account saving for arbitrary new uid. @@ -42,7 +43,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 16c43b482919740bb03ed3033b8a111f11634874..2a64e1908efb49be0d8e0b3fae22a5c956ff2106 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\simpletest\WebTestBase; +use Drupal\user\Entity\User; /** * Generates text using placeholders for dummy content to check user token @@ -49,8 +50,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 d7f9138ce77ae2eb24b591b9a309c7f55d6f0b39..0cd84b3eaf41c35a9b4f0112c1c77f98be7d1961 100644 --- a/core/modules/user/src/Tests/Views/BulkFormTest.php +++ b/core/modules/user/src/Tests/Views/BulkFormTest.php @@ -38,6 +38,7 @@ class BulkFormTest extends UserTestBase { public function testBulkForm() { // Login as a user without 'administer users'. $this->drupalLogin($this->drupalCreateUser(array('administer permissions'))); + $user_storage = $this->container->get('entity.manager')->getStorage('user'); // Create an user which actually can change users. $this->drupalLogin($this->drupalCreateUser(array('administer users'))); @@ -53,7 +54,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_storage->load($this->users[0]->id()); $roles = user_role_names(TRUE); unset($roles[RoleInterface::AUTHENTICATED_ID]); $role = key($roles); @@ -65,7 +66,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_storage->load($account->id()); $this->assertTrue($account->hasRole($role), 'The user now has the custom role.'); $edit = array( @@ -74,7 +76,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_storage->load($account->id()); $this->assertFalse($account->hasRole($role), 'The user no longer has the custom role.'); // Block a user using the bulk form. @@ -86,7 +89,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_storage->load($account->id()); $this->assertTrue($account->isBlocked(), 'The user is blocked.'); $this->assertNoRaw($account->label(), 'The user is not found in the table.'); @@ -105,7 +109,7 @@ public function testBulkForm() { 'action' => 'user_block_user_action', ); $this->drupalPostForm(NULL, $edit, t('Apply')); - $anonymous_account = user_load(0); + $anonymous_account = $user_storage->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 c97624e228ef32d387ce57b95683ae6c65e23af4..56124b26a991d5242640c0e8b27ada27c6f0e93a 100644 --- a/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php @@ -8,6 +8,7 @@ namespace Drupal\user\Tests\Views; use Drupal\views\Views; +use Drupal\user\Entity\User; /** * Tests the handler of the user: role field. @@ -36,7 +37,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 51017dcba302c60417768f66dbc97815c264e885..b877fb6b895b0400a326acfb0b46251f1c6acee3 100644 --- a/core/modules/user/src/Tests/Views/UserTestBase.php +++ b/core/modules/user/src/Tests/Views/UserTestBase.php @@ -9,6 +9,7 @@ use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; +use Drupal\user\Entity\User; /** * @todo. @@ -42,7 +43,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 33ed45fe49ab38aa7bd15afdbcbdbf9473e82b0c..07c84d04dbd6c7024f73aa92193d4dde183ffde4 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -177,7 +177,7 @@ function user_entity_extra_field_info() { * An array of user objects, indexed by uid. * * @see entity_load_multiple() - * @see user_load() + * @see \Drupal\user\Entity\User::load() * @see user_load_by_mail() * @see user_load_by_name() * @see \Drupal\Core\Entity\Query\QueryInterface @@ -208,7 +208,7 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) { * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. * Use \Drupal\user\Entity\User::load(). * - * @see user_load_multiple() + * @see \Drupal\user\Entity\User::loadMultiple() */ function user_load($uid, $reset = FALSE) { if ($reset) { @@ -226,7 +226,7 @@ function user_load($uid, $reset = FALSE) { * A fully-loaded $user object upon successful user load or FALSE if user * cannot be loaded. * - * @see user_load_multiple() + * @see \Drupal\user\Entity\User::loadMultiple() */ function user_load_by_mail($mail) { $users = entity_load_multiple_by_properties('user', array('mail' => $mail)); @@ -242,7 +242,7 @@ function user_load_by_mail($mail) { * A fully-loaded $user object upon successful user load or FALSE if user * cannot be loaded. * - * @see user_load_multiple() + * @see \Drupal\user\Entity\User::loadMultiple() */ function user_load_by_name($name) { $users = entity_load_multiple_by_properties('user', array('name' => $name)); @@ -660,7 +660,7 @@ function user_pass_rehash($password, $timestamp, $login, $uid) { * @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'); @@ -877,7 +877,7 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) { * Constructs a drupal_render() style array from an array of loaded users. * * @param $accounts - * An array of user accounts as returned by user_load_multiple(). + * An array of user accounts as returned by User::loadMultiple(). * @param $view_mode * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser.' * @param $langcode diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index 510d138172f90156e227f770c90ba93f38742da3..0439015e572d8717781176615ded9350ef9a41c7 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\SafeMarkup; +use Drupal\user\Entity\User; /** * Implements hook_token_info(). @@ -127,7 +128,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/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 2fc7fc4f821251eb551d47ec2361092076ab9926..6314b85535595113aa3ac6abc979660e240127e7 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -143,7 +143,7 @@ public function form(array $form, FormStateInterface $form_state) { if ($view->isLocked()) { $username = array( '#theme' => 'username', - '#account' => user_load($view->lock->owner), + '#account' => $this->entityManager->getStorage('user')->load($view->lock->owner), ); $lock_message_substitutions = array( '!user' => drupal_render($username),