Commit 8bcecca1 authored by Dries's avatar Dries
Browse files

Issue #1768576 by heyrocker, sun: Remove role names from the ->roles array.

parent 3da9d8b2
...@@ -2069,7 +2069,7 @@ function drupal_anonymous_user() { ...@@ -2069,7 +2069,7 @@ function drupal_anonymous_user() {
$user->uid = 0; $user->uid = 0;
$user->hostname = ip_address(); $user->hostname = ip_address();
$user->roles = array(); $user->roles = array();
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user'; $user->roles[DRUPAL_ANONYMOUS_RID] = DRUPAL_ANONYMOUS_RID;
return $user; return $user;
} }
......
...@@ -110,8 +110,8 @@ function _drupal_session_read($sid) { ...@@ -110,8 +110,8 @@ function _drupal_session_read($sid) {
// Add roles element to $user. // Add roles element to $user.
$user->roles = array(); $user->roles = array();
$user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; $user->roles[DRUPAL_AUTHENTICATED_RID] = DRUPAL_AUTHENTICATED_RID;
$user->roles += db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 1); $user->roles += db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->uid))->fetchAllKeyed(0, 0);
} }
elseif ($user) { elseif ($user) {
// The user is anonymous or blocked. Only preserve two fields from the // The user is anonymous or blocked. Only preserve two fields from the
......
...@@ -32,10 +32,10 @@ function attachLoad(&$queried_users, $load_revision = FALSE) { ...@@ -32,10 +32,10 @@ function attachLoad(&$queried_users, $load_revision = FALSE) {
$queried_users[$key]->data = unserialize($record->data); $queried_users[$key]->data = unserialize($record->data);
$queried_users[$key]->roles = array(); $queried_users[$key]->roles = array();
if ($record->uid) { if ($record->uid) {
$queried_users[$record->uid]->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; $queried_users[$record->uid]->roles[DRUPAL_AUTHENTICATED_RID] = DRUPAL_AUTHENTICATED_RID;
} }
else { else {
$queried_users[$record->uid]->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user'; $queried_users[$record->uid]->roles[DRUPAL_ANONYMOUS_RID] = DRUPAL_ANONYMOUS_RID;
} }
} }
...@@ -67,7 +67,7 @@ public function create(array $values) { ...@@ -67,7 +67,7 @@ public function create(array $values) {
$values['created'] = REQUEST_TIME; $values['created'] = REQUEST_TIME;
} }
// Users always have the authenticated user role. // Users always have the authenticated user role.
$values['roles'][DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; $values['roles'][DRUPAL_AUTHENTICATED_RID] = DRUPAL_AUTHENTICATED_RID;
return parent::create($values); return parent::create($values);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment