diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 3e3853a..3ed3ac8 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -15,6 +15,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Lock\DatabaseLockBackend; use Drupal\Core\Lock\LockBackendInterface; +use Drupal\user\Plugin\Core\Entity\User; /** * @file @@ -2046,12 +2047,14 @@ function drupal_get_hash_salt() { * @return Object - the user object. */ function drupal_anonymous_user() { - $user = new stdClass(); - $user->uid = 0; - $user->hostname = ip_address(); - $user->roles = array(); - $user->roles[DRUPAL_ANONYMOUS_RID] = DRUPAL_ANONYMOUS_RID; - return $user; + $values = array( + 'uid' => 0, + 'hostname' => ip_address(), + 'roles' => array( + DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, + ), + ); + return new User($values, 'user'); } /** diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php index a4bfd52..15894ad 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php @@ -33,7 +33,7 @@ function setUp() { parent::setUp(); $this->account = $this->drupalCreateUser(); - $this->anonymous = entity_create('user', (array) drupal_anonymous_user()); + $this->anonymous = drupal_anonymous_user(); } /**