Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.883
diff -u -r1.883 user.module
--- modules/user/user.module	28 Dec 2007 12:02:52 -0000	1.883
+++ modules/user/user.module	4 Jan 2008 20:50:46 -0000
@@ -1611,7 +1611,11 @@
  *   An associative array with the role id as the key and the role name as value.
  */
 function user_roles($membersonly = 0, $permission = 0) {
-  $roles = array();
+  // System roles take the first two positions.
+  $roles = array(
+    DRUPAL_ANONYMOUS_RID => NULL,
+    DRUPAL_AUTHENTICATED_RID => NULL
+  );
 
   if ($permission) {
     $result = db_query("SELECT r.* FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid WHERE p.perm LIKE '%%%s%%' ORDER BY r.name", $permission);
@@ -1624,6 +1628,14 @@
       $roles[$role->rid] = $role->name;
     }
   }
+
+  // Unset system roles if not matched.
+  foreach (array( DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID ) as $rid) {
+    if ($roles[$rid] === NULL) {
+      unset($roles[$rid]);
+    }
+  };
+
   return $roles;
 }
 
Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.13
diff -u -r1.13 user.admin.inc
--- modules/user/user.admin.inc	23 Dec 2007 13:17:20 -0000	1.13
+++ modules/user/user.admin.inc	4 Jan 2008 20:50:37 -0000
@@ -514,16 +514,10 @@
     $role_permissions[$role->rid] = $role->perm .',';
   }
 
+  // Retrieve role names for columns.
+  $role_names = user_roles();
   if (is_numeric($rid)) {
-    $result = db_query('SELECT rid, name FROM {role} r WHERE r.rid = %d ORDER BY name', $rid);
-  }
-  else {
-    $result = db_query('SELECT rid, name FROM {role} ORDER BY name');
-  }
-
-  $role_names = array();
-  while ($role = db_fetch_object($result)) {
-    $role_names[$role->rid] = $role->name;
+    $role_names = array($rid => $role_names[$rid]);
   }
 
   // Render role/permission overview:
