summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2015-04-27 02:00:41 (GMT)
committerxjm2015-04-27 02:00:41 (GMT)
commitdb27d7953e1bc8929bb067b960f2a18c4f539b9d (patch)
treede1977700015299efa19c9a669317ba150be130a
parentd0ac10561d8a5790e5658bc2456de09819635fc4 (diff)
Issue #2322195 by rpayanm, nlisgo, cilefen, balagan, LinL, akashjain132, filijonka, epari.siva, Tebro, Temoor, pcambra, unstatu, Poornima3, Shivam Agarwal, abhi170893, Dom., PieterJanPut, Mile23, JeroenT, disasm: Replace all instances of user_load(), user_load_multiple(), entity_load('user') and entity_load_multiple('user') with static method calls
-rw-r--r--core/includes/install.core.inc4
-rw-r--r--core/lib/Drupal/Core/Utility/Token.php2
-rw-r--r--core/modules/contact/src/Tests/Views/ContactLinkTest.php3
-rw-r--r--core/modules/content_translation/src/Tests/Views/TranslationLinkTest.php5
-rw-r--r--core/modules/dblog/src/Controller/DbLogController.php12
-rw-r--r--core/modules/forum/forum.module3
-rw-r--r--core/modules/node/node.tokens.inc3
-rw-r--r--core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php3
-rw-r--r--core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php3
-rw-r--r--core/modules/node/src/Tests/NodeAccessLanguageTest.php3
-rw-r--r--core/modules/rest/src/Tests/DeleteTest.php5
-rw-r--r--core/modules/simpletest/src/BrowserTestBase.php2
-rw-r--r--core/modules/simpletest/src/WebTestBase.php2
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCrudHookTest.php3
-rw-r--r--core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php5
-rw-r--r--core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php3
-rw-r--r--core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php3
-rw-r--r--core/modules/system/token.api.php3
-rw-r--r--core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php10
-rw-r--r--core/modules/user/src/Tests/UserAdminListingTest.php3
-rw-r--r--core/modules/user/src/Tests/UserAdminTest.php19
-rw-r--r--core/modules/user/src/Tests/UserCancelTest.php81
-rw-r--r--core/modules/user/src/Tests/UserDeleteTest.php11
-rw-r--r--core/modules/user/src/Tests/UserLoginTest.php7
-rw-r--r--core/modules/user/src/Tests/UserPasswordResetTest.php2
-rw-r--r--core/modules/user/src/Tests/UserPictureTest.php5
-rw-r--r--core/modules/user/src/Tests/UserRolesAssignmentTest.php4
-rw-r--r--core/modules/user/src/Tests/UserSaveTest.php3
-rw-r--r--core/modules/user/src/Tests/UserTokenReplaceTest.php5
-rw-r--r--core/modules/user/src/Tests/Views/BulkFormTest.php14
-rw-r--r--core/modules/user/src/Tests/Views/HandlerFieldRoleTest.php3
-rw-r--r--core/modules/user/src/Tests/Views/UserTestBase.php3
-rw-r--r--core/modules/user/user.module12
-rw-r--r--core/modules/user/user.tokens.inc3
-rw-r--r--core/modules/views_ui/src/ViewEditForm.php2
35 files changed, 167 insertions, 87 deletions
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 9b947ca..d858875 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -26,7 +26,7 @@ use Symfony\Component\DependencyInjection\Reference;
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 6d3b4a2..11427ba 100644
--- a/core/lib/Drupal/Core/Utility/Token.php
+++ b/core/lib/Drupal/Core/Utility/Token.php
@@ -40,7 +40,7 @@ use Drupal\Core\Language\LanguageManagerInterface;
* // 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 bb7fb91..320deb0 100644
--- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php
@@ -9,6 +9,7 @@ namespace Drupal\contact\Tests\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
+use Drupal\user\Entity\User;
/**
* Tests the contact link field.
@@ -55,7 +56,7 @@ class ContactLinkTest extends ViewTestBase {
*/
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 b37666e..485f6f5 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\views\Tests\ViewTestBase;
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 @@ class TranslationLinkTest extends ContentTranslationTestBase {
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 d6dcfab..b896be2 100644
--- a/core/modules/dblog/src/Controller/DbLogController.php
+++ b/core/modules/dblog/src/Controller/DbLogController.php
@@ -54,6 +54,13 @@ class DbLogController extends ControllerBase {
protected $formBuilder;
/**
+ * The user storage.
+ *
+ * @var \Drupal\user\UserStorageInterface
+ */
+ protected $userStorage;
+
+ /**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
@@ -82,6 +89,7 @@ class DbLogController extends ControllerBase {
$this->moduleHandler = $module_handler;
$this->dateFormatter = $date_formatter;
$this->formBuilder = $form_builder;
+ $this->userStorage = $this->entityManager()->getStorage('user');
}
/**
@@ -188,7 +196,7 @@ class DbLogController extends ControllerBase {
}
$username = array(
'#theme' => 'username',
- '#account' => user_load($dblog->uid),
+ '#account' => $this->userStorage->load($dblog->uid),
);
$rows[] = array(
'data' => array(
@@ -239,7 +247,7 @@ class DbLogController extends ControllerBase {
$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 4ddc775..026967e 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -16,6 +16,7 @@ use Drupal\Core\Form\FormStateInterface;
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 4f4b066..7f8d50a 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 1fedcb5..62a7b0c 100644
--- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php
+++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php
@@ -10,6 +10,7 @@ namespace Drupal\node\Tests;
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 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
// 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 a9ee922..1351617 100644
--- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php
+++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php
@@ -9,6 +9,7 @@ namespace Drupal\node\Tests;
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 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
// 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 6345007..949c385 100644
--- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php
+++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php
@@ -10,6 +10,7 @@ namespace Drupal\node\Tests;
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 @@ class NodeAccessLanguageTest extends NodeTestBase {
// 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 5a86d77..f205f30 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 @@ class DeleteTest extends RESTTestBase {
$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 6cba2e0..d3bf74f 100644
--- a/core/modules/simpletest/src/BrowserTestBase.php
+++ b/core/modules/simpletest/src/BrowserTestBase.php
@@ -678,7 +678,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
* $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 de20658..2987411 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -672,7 +672,7 @@ abstract class WebTestBase extends TestBase {
* $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 deff706..0e62fce 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\block\Entity\Block;
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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
));
$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 358c883..45e0e92 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\Component\Utility\SafeMarkup;
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 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
// 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 c44871a..342151e 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 @@ namespace Drupal\database_test\Form;
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 @@ class DatabaseTestForm extends FormBase {
$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 644dd49..c4b8017 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 @@ namespace Drupal\url_alter_test;
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 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
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 ed7c74c..51133de 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 d766378..e2dd03d 100644
--- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
+++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php
@@ -38,6 +38,13 @@ class UserSelection extends SelectionBase {
protected $connection;
/**
+ * The user storage.
+ *
+ * @var \Drupal\user\UserStorageInterface
+ */
+ protected $userStorage;
+
+ /**
* Constructs a new UserSelection object.
*
* @param array $configuration
@@ -59,6 +66,7 @@ class UserSelection extends SelectionBase {
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 @@ class UserSelection extends SelectionBase {
$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 bf4681e..fbf3197 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 @@ class UserAdminListingTest extends WebTestBase {
$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 06b5f72..691839d 100644
--- a/core/modules/user/src/Tests/UserAdminTest.php
+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -39,6 +39,8 @@ class UserAdminTest extends WebTestBase {
$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 @@ class UserAdminTest extends WebTestBase {
$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 @@ class UserAdminTest extends WebTestBase {
// 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 @@ class UserAdminTest extends WebTestBase {
// 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 92e7ce0..2d49397 100644
--- a/core/modules/user/src/Tests/UserCancelTest.php
+++ b/core/modules/user/src/Tests/UserCancelTest.php
@@ -41,12 +41,14 @@ class UserCancelTest extends WebTestBase {
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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
* 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 @@ class UserCancelTest extends WebTestBase {
->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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
*/
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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
$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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
\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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
// 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 @@ class UserCancelTest extends WebTestBase {
\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 @@ class UserCancelTest extends WebTestBase {
$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 1c91311..656373d 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 @@ class UserDeleteTest extends WebTestBase {
$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 @@ class UserDeleteTest extends WebTestBase {
->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 27ffa2a..31bcc32 100644
--- a/core/modules/user/src/Tests/UserLoginTest.php
+++ b/core/modules/user/src/Tests/UserLoginTest.php
@@ -9,6 +9,7 @@ namespace Drupal\user\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Password\PhpassHashedPassword;
+use Drupal\user\Entity\User;
/**
* Ensure that login works as expected.
@@ -126,7 +127,8 @@ 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->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 @@ 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->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 c48199a..90bdee8 100644
--- a/core/modules/user/src/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/src/Tests/UserPasswordResetTest.php
@@ -56,7 +56,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase {
// 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 2938e67..4f70d44 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 @@ class UserPictureTest extends WebTestBase {
$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 79addc2..8e164f5 100644
--- a/core/modules/user/src/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/src/Tests/UserRolesAssignmentTest.php
@@ -85,7 +85,9 @@ class UserRolesAssignmentTest extends WebTestBase {
* 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 a2eaf5d..528ef8d 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 @@ class UserSaveTest extends WebTestBase {
$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 16c43b4..2a64e19 100644
--- a/core/modules/user/src/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php
@@ -10,6 +10,7 @@ namespace Drupal\user\Tests;
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 @@ class UserTokenReplaceTest extends WebTestBase {
$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 d7f9138..0cd84b3 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 @@ class BulkFormTest extends UserTestBase {
$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 @@ class BulkFormTest extends UserTestBase {
);
$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 @@ class BulkFormTest extends UserTestBase {
);
$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 @@ class BulkFormTest extends UserTestBase {
);
$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 @@ class BulkFormTest extends UserTestBase {
'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 c97624e..56124b2 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 @@ class HandlerFieldRoleTest extends UserTestBase {
$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..b877fb6 100644
--- a/core/modules/user/src/Tests/Views/UserTestBase.php
+++ b/core/modules/user/src/Tests/Views/UserTestBase.php
@@ -9,6 +9,7 @@ namespace Drupal\user\Tests\Views;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
+use Drupal\user\Entity\User;
/**
* @todo.
@@ -42,7 +43,7 @@ abstract class UserTestBase extends ViewTestBase {
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 33ed45f..07c84d0 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 510d138..0439015 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 2fc7fc4..6314b85 100644
--- a/core/modules/views_ui/src/ViewEditForm.php
+++ b/core/modules/views_ui/src/ViewEditForm.php
@@ -143,7 +143,7 @@ class ViewEditForm extends ViewFormBase {
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),