diff --git a/core/includes/session.inc b/core/includes/session.inc index 17c73d7..c68c33c 100644 --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -108,9 +108,8 @@ function _drupal_session_read($sid) { // active user. if ($user && $user->uid > 0 && $user->status == 1) { // Add roles element to $user. - $user->roles = array(); - $user->roles[DRUPAL_AUTHENTICATED_RID] = DRUPAL_AUTHENTICATED_RID; - $user->roles += db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 0); + $rids = db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchCol(); + $user->roles = array_merge(array(DRUPAL_AUTHENTICATED_RID), $rids); } elseif ($user) { // The user is anonymous or blocked. Only preserve two fields from the diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index bc9fadf..bbc3b84 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -387,15 +387,7 @@ public function updateOriginalValues() { foreach ($this->getPropertyDefinitions() as $name => $definition) { if (empty($definition['computed']) && !empty($this->fields[$name])) { foreach ($this->fields[$name] as $langcode => $field) { - // If the value is array we need to filter out potential harmfull - // values like array(0 => NULL) before sending to storage mechanisms - // so that we avoid potential exceptions / empty values stored in - // the database or other storage locations. - $value = $field->getValue(); - if (is_array($value)) { - $value = array_filter($value); - } - $this->values[$name][$langcode] = $value; + $this->values[$name][$langcode] = $field->getValue(); } } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index 225c708..5dc6330 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -63,8 +63,8 @@ function testUninstallProcess() { // Check the UI language. // @todo: If the global user is an EntityBCDecorator, getting the roles - // roles from it within LocaleLookup results in a loop that invokes - // LocaleLookup again. + // from it within LocaleLookup results in a loop that invokes LocaleLookup + // again. global $user; $user = drupal_anonymous_user(); diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 78a3139..8a17409 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -393,8 +393,8 @@ function hook_node_grants_alter(&$grants, $account, $op) { if ($op != 'view' && !empty($restricted)) { // Now check the roles for this account against the restrictions. - foreach ($restricted as $role_id) { - if (isset($account->roles[$role_id])) { + foreach ($account->roles as $rid) { + if (in_array($rid, $restricted)) { $grants = array(); } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 6b7b150..f4acf0d 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -407,7 +407,7 @@ function user_password($length = 10) { * Determine the permissions for one or more roles. * * @param $roles - * An array whose keys are the role IDs of interest, such as $user->roles. + * An array whose values are the role IDs of interest, such as $user->roles. * * @return * An array indexed by role ID. Each value is an array whose keys are the @@ -2118,7 +2118,7 @@ function user_multiple_role_edit($accounts, $operation, $rid) { // For efficiency manually save the original account before applying // any changes. $account->original = clone $account; - $account->roles[count($account->roles)] = $rid; + $account->roles[] = $rid; $account->save(); } } @@ -2297,7 +2297,7 @@ function user_build_filter_query(SelectInterface $query) { if ($key == 'permission') { $account = entity_create('user', array()); $account->uid = 'user_filter'; - $account->roles = array(DRUPAL_AUTHENTICATED_RID => 1); + $account->roles[] = DRUPAL_AUTHENTICATED_RID; if (user_access($value, $account)) { continue; }