diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 332be12..7ff45ce 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2053,16 +2053,13 @@ function drupal_hash_base64($data) { * The user object. */ function drupal_anonymous_user() { - $values = array( + return (object) array( 'uid' => 0, 'hostname' => ip_address(), 'roles' => array( DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, ), ); - // @todo: This is really ugly but not sure how to change it. - $definitions = array(); - return new EntityBCDecorator(new User($values, 'user'), $definitions); } /** diff --git a/core/includes/session.inc b/core/includes/session.inc index 07a8480..31e67a6 100644 --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -80,13 +80,7 @@ function _drupal_session_read($sid) { // cookies (eg. web crawlers). $insecure_session_name = substr(session_name(), 1); if (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name])) { - $user = (object)array( - 'uid' => 0, - 'hostname' => ip_address(), - 'roles' => array( - DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, - ), - ); + $user = drupal_anonymous_user(); return ''; } @@ -119,26 +113,14 @@ function _drupal_session_read($sid) { elseif ($user) { // The user is anonymous or blocked. Only preserve two fields from the // {sessions} table. - $account = (object)array( - 'uid' => 0, - 'hostname' => ip_address(), - 'roles' => array( - DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, - ), - ); + $account = drupal_anonymous_user(); $account->session = $user->session; $account->timestamp = $user->timestamp; $user = $account; } else { // The session has expired. - $user = (object)array( - 'uid' => 0, - 'hostname' => ip_address(), - 'roles' => array( - DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, - ), - ); + $user = drupal_anonymous_user(); $user->session = ''; } @@ -273,13 +255,7 @@ function drupal_session_initialize() { // processes (like drupal_get_token()) needs to know the future // session ID in advance. $GLOBALS['lazy_session'] = TRUE; - $user = (object) array( - 'uid' => 0, - 'hostname' => ip_address(), - 'roles' => array( - DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, - ), - ); + $user = drupal_anonymous_user(); // Less random sessions (which are much faster to generate) are used for // anonymous users than are generated in drupal_session_regenerate() when // a user becomes authenticated. @@ -457,13 +433,7 @@ function _drupal_session_destroy($sid) { // Reset $_SESSION and $user to prevent a new session from being started // in drupal_session_commit(). $_SESSION = array(); - $user = (object) array( - 'uid' => 0, - 'hostname' => ip_address(), - 'roles' => array( - DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, - ), - ); + $user = drupal_anonymous_user(); // Unset the session cookies. _drupal_session_delete_cookie(session_name()); diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index e57f4bb..965de84 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -121,6 +121,9 @@ class DatabaseStorageController implements EntityStorageControllerInterface { */ public function __construct($entityType) { $this->entityType = $entityType; + if (!function_exists('entity_get_info')) { + debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + } $this->entityInfo = entity_get_info($entityType); $this->entityCache = array(); $this->hookLoadArguments = array(); diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index c3931d8..f619e59 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -690,7 +690,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { $role_names = array($rid => $role_names[$rid]); } // Fetch permissions for all roles or the one selected role. - $role_permissions = user_role_permissions($role_names); + $role_permissions = user_role_permissions(array_keys($role_names)); // Store $role_names for use when saving the data. $form['role_names'] = array( diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 4612317..2815218 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -753,6 +753,9 @@ function user_template_preprocess_default_variables_alter(&$variables) { */ function template_preprocess_username(&$variables) { $account = $variables['account']; + if ($account instanceof User) { + $account = $account->getBCEntity(); + } $variables['extra'] = ''; if (empty($account->uid)) {