diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index f4106fb..71222b7 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -145,14 +145,14 @@ const DRUPAL_BOOTSTRAP_LANGUAGE = 6;
 const DRUPAL_BOOTSTRAP_FULL = 7;
 
 /**
- * Role ID for anonymous users; should match what's in the "role" table.
+ * Role name for anonymous users; should match what's in the "role" table.
  */
-const DRUPAL_ANONYMOUS_RID = 1;
+const DRUPAL_ANONYMOUS_ROLE = 'anonymous user';
 
 /**
- * Role ID for authenticated users; should match what's in the "role" table.
+ * Role name for authenticated users; should match what's in the "role" table.
  */
-const DRUPAL_AUTHENTICATED_RID = 2;
+const DRUPAL_AUTHENTICATED_ROLE = 'authenticated user';
 
 /**
  * The number of bytes in a kilobyte.
diff --git a/core/modules/block/block.install b/core/modules/block/block.install
index c2d4185..79c27a6 100644
--- a/core/modules/block/block.install
+++ b/core/modules/block/block.install
@@ -117,16 +117,16 @@ function block_schema() {
         'not null' => TRUE,
         'description' => "The block's unique delta within module, from {block}.delta.",
       ),
-      'rid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
+      'role' => array(
+        'type' => 'varchar',
+        'length' => 64,
         'not null' => TRUE,
-        'description' => "The user's role ID from {users_roles}.rid.",
+        'description' => "The role name from {role}.name.",
       ),
     ),
-    'primary key' => array('module', 'delta', 'rid'),
+    'primary key' => array('module', 'delta', 'role'),
     'indexes' => array(
-      'rid' => array('rid'),
+      'role' => array('role'),
     ),
   );
 
diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test
index 9a77853..111a315 100644
--- a/core/modules/comment/comment.test
+++ b/core/modules/comment/comment.test
@@ -521,7 +521,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     // Prepare for anonymous comment submission (comment approval enabled).
     variable_set('user_register', USER_REGISTER_VISITORS);
     $this->drupalLogin($this->admin_user);
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -545,7 +545,7 @@ class CommentInterfaceTest extends CommentHelperCase {
 
     // Prepare for anonymous comment submission (no approval required).
     $this->drupalLogin($this->admin_user);
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -709,7 +709,7 @@ class CommentInterfaceTest extends CommentHelperCase {
     variable_set('user_register', $info['user_register']);
 
     // Change user permissions.
-    $rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID);
+    $rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_ROLE);
     $perms = array_intersect_key($info, array('access comments' => 1, 'post comments' => 1, 'skip comment approval' => 1, 'edit own comments' => 1));
     user_role_change_permissions($rid, $perms);
 
@@ -971,7 +971,7 @@ class CommentAnonymous extends CommentHelperCase {
   function testAnonymous() {
     $this->drupalLogin($this->admin_user);
     // Enabled anonymous user comments.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -1058,7 +1058,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->drupalLogout();
 
     // Reset.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => FALSE,
       'post comments' => FALSE,
       'skip comment approval' => FALSE,
@@ -1077,7 +1077,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->assertNoFieldByName('subject', '', t('Subject field not found.'));
     $this->assertNoFieldByName("comment_body[$langcode][0][value]", '', t('Comment field not found.'));
 
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => FALSE,
       'skip comment approval' => FALSE,
@@ -1087,7 +1087,7 @@ class CommentAnonymous extends CommentHelperCase {
     $this->assertLink('Log in', 1, t('Link to log in was found.'));
     $this->assertLink('register', 1, t('Link to register was found.'));
 
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => FALSE,
       'post comments' => TRUE,
       'skip comment approval' => TRUE,
@@ -1454,7 +1454,7 @@ class CommentApprovalTest extends CommentHelperCase {
    */
   function testApprovalAdminInterface() {
     // Set anonymous comments to require approval.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -1523,7 +1523,7 @@ class CommentApprovalTest extends CommentHelperCase {
    */
   function testApprovalNodeInterface() {
     // Set anonymous comments to require approval.
-    user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
+    user_role_change_permissions(DRUPAL_ANONYMOUS_ROLE, array(
       'access comments' => TRUE,
       'post comments' => TRUE,
       'skip comment approval' => FALSE,
@@ -1602,13 +1602,13 @@ class CommentBlockFunctionalTest extends CommentHelperCase {
     // Test that a user without the 'access comments' permission cannot see the
     // block.
     $this->drupalLogout();
-    user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
+    user_role_revoke_permissions(DRUPAL_ANONYMOUS_ROLE, array('access comments'));
     // drupalCreateNode() does not automatically flush content caches unlike
     // posting a node from a node form.
     cache_clear_all();
     $this->drupalGet('');
     $this->assertNoText($block['title'], t('Block was not found.'));
-    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments'));
+    user_role_grant_permissions(DRUPAL_ANONYMOUS_ROLE, array('access comments'));
 
     // Test that a user with the 'access comments' permission can see the
     // block.
diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test
index 5936937..6386746 100644
--- a/core/modules/field/modules/text/text.test
+++ b/core/modules/field/modules/text/text.test
@@ -212,8 +212,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
     $format = filter_format_load($edit['format']);
     $format_id = $format->format;
     $permission = filter_permission_name($format);
-    $rid = max(array_keys($this->web_user->roles));
-    user_role_grant_permissions($rid, array($permission));
+    $role = max(array_keys($this->web_user->roles));
+    user_role_grant_permissions($role, array($permission));
     $this->drupalLogin($this->web_user);
 
     // Display edition form.
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index f7d4552..306bf1e 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -195,9 +195,9 @@ function user_admin_account() {
   $accounts = array();
   foreach ($result as $account) {
     $users_roles = array();
-    $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
+    $roles_result = db_query('SELECT role_name FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
     foreach ($roles_result as $user_role) {
-      $users_roles[] = $roles[$user_role->rid];
+      $users_roles[] = $roles[$user_role->role_name];
     }
     asort($users_roles);
 
@@ -280,8 +280,8 @@ function user_admin_settings() {
   // Do not allow users to set the anonymous or authenticated user roles as the
   // administrator role.
   $roles = user_roles();
-  unset($roles[DRUPAL_ANONYMOUS_RID]);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  unset($roles[DRUPAL_ANONYMOUS_ROLE]);
+  unset($roles[DRUPAL_AUTHENTICATED_ROLE]);
   $roles[0] = t('disabled');
 
   $form['admin_role']['user_admin_role'] = array(
@@ -648,12 +648,12 @@ function user_admin_settings() {
  * @see user_admin_permissions_submit()
  * @see theme_user_admin_permissions()
  */
-function user_admin_permissions($form, $form_state, $rid = NULL) {
+function user_admin_permissions($form, $form_state, $role_name = NULL) {
 
   // Retrieve role names for columns.
   $role_names = user_roles();
-  if (is_numeric($rid)) {
-    $role_names = array($rid => $role_names[$rid]);
+  if (!empty($role_name)) {
+    $role_names = array($role_name => $role_names[$role_name]);
   }
   // Fetch permissions for all roles or the one selected role.
   $role_permissions = user_role_permissions($role_names);
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index f7175c3..a460f88 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -54,11 +54,11 @@ function user_schema() {
   $schema['role_permission'] = array(
     'description' => 'Stores the permissions assigned to user roles.',
     'fields' => array(
-      'rid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
+      'role_name' => array(
+        'type' => 'varchar',
+        'length' => 64,
         'not null' => TRUE,
-        'description' => 'Foreign Key: {role}.rid.',
+        'description' => 'Foreign Key: {role}.name.',
       ),
       'permission' => array(
         'type' => 'varchar',
@@ -75,14 +75,14 @@ function user_schema() {
         'description' => "The module declaring the permission.",
       ),
     ),
-    'primary key' => array('rid', 'permission'),
+    'primary key' => array('role_name', 'permission'),
     'indexes' => array(
       'permission' => array('permission'),
     ),
     'foreign keys' => array(
       'role' => array(
         'table' => 'roles',
-        'columns' => array('rid' => 'rid'),
+        'columns' => array('role_name' => 'name'),
       ),
     ),
   );
@@ -90,18 +90,18 @@ function user_schema() {
   $schema['role'] = array(
     'description' => 'Stores user roles.',
     'fields' => array(
-      'rid' => array(
-        'type' => 'serial',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'description' => 'Primary Key: Unique role ID.',
-      ),
       'name' => array(
         'type' => 'varchar',
         'length' => 64,
         'not null' => TRUE,
         'default' => '',
         'description' => 'Unique role name.',
+      ),
+      'label' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'default' => '',
+        'description' => 'Role label.',
         'translatable' => TRUE,
       ),
       'weight' => array(
@@ -111,10 +111,7 @@ function user_schema() {
         'description' => 'The weight of this role in listings and the user interface.',
       ),
     ),
-    'unique keys' => array(
-      'name' => array('name'),
-    ),
-    'primary key' => array('rid'),
+    'primary key' => array('name'),
     'indexes' => array(
       'name_weight' => array('name', 'weight'),
     ),
@@ -257,17 +254,17 @@ function user_schema() {
         'default' => 0,
         'description' => 'Primary Key: {users}.uid for user.',
       ),
-      'rid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
+      'role_name' => array(
+        'type' => 'varchar',
+        'length' => 64,
         'not null' => TRUE,
-        'default' => 0,
-        'description' => 'Primary Key: {role}.rid for role.',
+        'default' => '',
+        'description' => 'Primary Key: {role}.name for role.',
       ),
     ),
-    'primary key' => array('uid', 'rid'),
+    'primary key' => array('uid', 'role_name'),
     'indexes' => array(
-      'rid' => array('rid'),
+      'role_name' => array('role_name'),
     ),
     'foreign keys' => array(
       'user' => array(
@@ -276,7 +273,7 @@ function user_schema() {
       ),
       'role' => array(
         'table' => 'roles',
-        'columns' => array('rid' => 'rid'),
+        'columns' => array('role_name' => 'name'),
       ),
     ),
   );
@@ -312,28 +309,16 @@ function user_install() {
     ->execute();
 
   // Built-in roles.
-  $rid_anonymous = db_insert('role')
-    ->fields(array('name' => 'anonymous user', 'weight' => 0))
+  db_insert('role')->fields(array(
+    	'name' => DRUPAL_ANONYMOUS_ROLE,
+    	'label' => 'Anonymous user',
+    	'weight' => 0))
     ->execute();
-  $rid_authenticated = db_insert('role')
-    ->fields(array('name' => 'authenticated user', 'weight' => 1))
+  db_insert('role')->fields(array(
+    	'name' => DRUPAL_AUTHENTICATED_ROLE,
+    	'label' => 'Authenticated user',
+    	'weight' => 1))
     ->execute();
-
-  // Sanity check to ensure the anonymous and authenticated role IDs are the
-  // same as the drupal defined constants. In certain situations, this will
-  // not be true.
-  if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
-    db_update('role')
-      ->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
-      ->condition('rid', $rid_anonymous)
-      ->execute();
-  }
-  if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
-    db_update('role')
-      ->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
-      ->condition('rid', $rid_authenticated)
-      ->execute();
-  }
 }
 
 /**
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 5919b78..fb61f28 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -471,12 +471,12 @@ function user_save($account, $edit = array()) {
           ->condition('uid', $account->uid)
           ->execute();
 
-        $query = db_insert('users_roles')->fields(array('uid', 'rid'));
-        foreach (array_keys($account->roles) as $rid) {
-          if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
+        $query = db_insert('users_roles')->fields(array('uid', 'role_name'));
+        foreach ($account->roles as $role_name) {
+          if (!in_array($role_name, array(DRUPAL_ANONYMOUS_ROLE, DRUPAL_AUTHENTICATED_ROLE))) {
             $query->values(array(
               'uid' => $account->uid,
-              'rid' => $rid,
+              'role_name' => $role_name,
             ));
           }
         }
@@ -534,7 +534,7 @@ function user_save($account, $edit = array()) {
       }
 
       // Make sure $account is properly initialized.
-      $account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
+      $account->roles[DRUPAL_AUTHENTICATED_ROLE] = DRUPAL_AUTHENTICATED_ROLE;
 
       field_attach_insert('user', $account);
       $edit = (array) $account;
@@ -543,12 +543,12 @@ function user_save($account, $edit = array()) {
 
       // Save user roles.
       if (count($account->roles) > 1) {
-        $query = db_insert('users_roles')->fields(array('uid', 'rid'));
-        foreach (array_keys($account->roles) as $rid) {
-          if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
+        $query = db_insert('users_roles')->fields(array('uid', 'role_name'));
+        foreach ($account->roles as $role_name) {
+          if (!in_array($role_name, array(DRUPAL_ANONYMOUS_ROLE, DRUPAL_AUTHENTICATED_ROLE))) {
             $query->values(array(
               'uid' => $account->uid,
-              'rid' => $rid,
+              'role_name' => $role_name,
             ));
           }
         }
@@ -694,29 +694,29 @@ function user_role_permissions($roles = array()) {
   $role_permissions = $fetch = array();
 
   if ($roles) {
-    foreach ($roles as $rid => $name) {
-      if (isset($cache[$rid])) {
-        $role_permissions[$rid] = $cache[$rid];
+    foreach ($roles as $role_name) {
+      if (isset($cache[$role_name])) {
+        $role_permissions[$role_name] = $cache[$role_name];
       }
       else {
-        // Add this rid to the list of those needing to be fetched.
-        $fetch[] = $rid;
+        // Add this role name to the list of those needing to be fetched.
+        $fetch[] = $role_name;
         // Prepare in case no permissions are returned.
-        $cache[$rid] = array();
+        $cache[$role_name] = array();
       }
     }
 
     if ($fetch) {
       // Get from the database permissions that were not in the static variable.
-      // Only role IDs with at least one permission assigned will return rows.
-      $result = db_query("SELECT rid, permission FROM {role_permission} WHERE rid IN (:fetch)", array(':fetch' => $fetch));
+      // Only role names with at least one permission assigned will return rows.
+      $result = db_query("SELECT role_name, permission FROM {role_permission} WHERE role_name IN (:fetch)", array(':fetch' => $fetch));
 
       foreach ($result as $row) {
-        $cache[$row->rid][$row->permission] = TRUE;
+        $cache[$row->role_name][$row->permission] = TRUE;
       }
-      foreach ($fetch as $rid) {
-        // For every rid, we know we at least assigned an empty array.
-        $role_permissions[$rid] = $cache[$rid];
+      foreach ($fetch as $role_name) {
+        // For every role name, we know we at least assigned an empty array.
+        $role_permissions[$role_name] = $cache[$role_name];
       }
     }
   }
@@ -1041,18 +1041,18 @@ function user_account_form(&$form, &$form_state) {
   // @todo This should be solved more elegantly. See issue #119038.
   $checkbox_authenticated = array(
     '#type' => 'checkbox',
-    '#title' => $roles[DRUPAL_AUTHENTICATED_RID],
+    '#title' => $roles[DRUPAL_AUTHENTICATED_ROLE],
     '#default_value' => TRUE,
     '#disabled' => TRUE,
   );
-  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  unset($roles[DRUPAL_AUTHENTICATED_ROLE]);
   $form['account']['roles'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Roles'),
     '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()),
     '#options' => $roles,
     '#access' => $roles && user_access('administer permissions'),
-    DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
+    DRUPAL_AUTHENTICATED_ROLE => $checkbox_authenticated,
   );
 
   $form['account']['notify'] = array(
@@ -2801,7 +2801,7 @@ function user_mail_tokens(&$replacements, $data, $options) {
  *   permission are returned.
  *
  * @return
- *   An associative array with the role id as the key and the role name as
+ *   An associative array with the role name as the key and the role label as
  *   value.
  */
 function user_roles($membersonly = FALSE, $permission = NULL) {
@@ -2810,7 +2810,7 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
   // Do not cache roles for specific permissions. This data is not requested
   // frequently enough to justify the additional memory use.
   if (empty($permission)) {
-    $cid = $membersonly ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
+    $cid = $membersonly ? DRUPAL_AUTHENTICATED_ROLE : DRUPAL_ANONYMOUS_ROLE;
     if (isset($user_roles[$cid])) {
       return $user_roles[$cid];
     }
@@ -2818,29 +2818,29 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
 
   $query = db_select('role', 'r');
   $query->addTag('translatable');
-  $query->fields('r', array('rid', 'name'));
+  $query->fields('r', array('name', 'label'));
   $query->orderBy('weight');
-  $query->orderBy('name');
+  $query->orderBy('label');
   if (!empty($permission)) {
-    $query->innerJoin('role_permission', 'p', 'r.rid = p.rid');
+    $query->innerJoin('role_permission', 'p', 'r.name = p.role_name');
     $query->condition('p.permission', $permission);
   }
   $result = $query->execute();
 
   $roles = array();
   foreach ($result as $role) {
-    switch ($role->rid) {
-      // We only translate the built in role names
-      case DRUPAL_ANONYMOUS_RID:
+    switch ($role->name) {
+      // We only translate the built in role labels.
+      case DRUPAL_ANONYMOUS_ROLE:
         if (!$membersonly) {
-          $roles[$role->rid] = t($role->name);
+          $roles[$role->name] = t($role->label);
         }
         break;
-      case DRUPAL_AUTHENTICATED_RID:
-        $roles[$role->rid] = t($role->name);
+      case DRUPAL_AUTHENTICATED_ROLE:
+        $roles[$role->name] = t($role->label);
         break;
       default:
-        $roles[$role->rid] = $role->name;
+        $roles[$role->name] = $role->label;
     }
   }
 
@@ -2853,41 +2853,21 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
 }
 
 /**
- * Fetches a user role by role ID.
- *
- * @param $rid
- *   An integer representing the role ID.
- *
- * @return
- *   A fully-loaded role object if a role with the given ID exists, or FALSE
- *   otherwise.
- *
- * @see user_role_load_by_name()
- */
-function user_role_load($rid) {
-  return db_select('role', 'r')
-    ->fields('r')
-    ->condition('rid', $rid)
-    ->execute()
-    ->fetchObject();
-}
-
-/**
  * Fetches a user role by role name.
  *
- * @param $role_name
- *   A string representing the role name.
+ * @param string $name
+ *   An string representing the role name.
  *
- * @return
+ * @return object
  *   A fully-loaded role object if a role with the given name exists, or FALSE
  *   otherwise.
  *
- * @see user_role_load()
+ * @see user_role_load_by_name()
  */
-function user_role_load_by_name($role_name) {
+function user_role_load($name) {
   return db_select('role', 'r')
     ->fields('r')
-    ->condition('name', $role_name)
+    ->condition('name', $name)
     ->execute()
     ->fetchObject();
 }
@@ -2896,8 +2876,7 @@ function user_role_load_by_name($role_name) {
  * Save a user role to the database.
  *
  * @param $role
- *   A role object to modify or add. If $role->rid is not specified, a new
- *   role will be created.
+ *   A role object to modify or add.
  * @return
  *   Status constant indicating if role was created or updated.
  *   Failure to write the user role record will return FALSE. Otherwise.
@@ -2919,14 +2898,20 @@ function user_role_save($role) {
   // Let modules modify the user role before it is saved to the database.
   module_invoke_all('user_role_presave', $role);
 
-  if (!empty($role->rid) && $role->name) {
-    $status = drupal_write_record('role', $role, 'rid');
-    module_invoke_all('user_role_update', $role);
-  }
-  else {
+  $exists = db_select('role', 'r')
+    ->fields('r', 'name')
+    ->condition('name', $role->name)
+    ->execute()
+    ->fetchAll();
+
+  if (empty($exists)) {
     $status = drupal_write_record('role', $role);
     module_invoke_all('user_role_insert', $role);
   }
+  else {
+    $status = drupal_write_record('role', $role, 'name');
+    module_invoke_all('user_role_update', $role);
+  }
 
   // Clear the user access cache.
   drupal_static_reset('user_access');
@@ -2938,26 +2923,21 @@ function user_role_save($role) {
 /**
  * Delete a user role from database.
  *
- * @param $role
- *   A string with the role name, or an integer with the role ID.
+ * @param $role_name
+ *   A string with the role name.
  */
-function user_role_delete($role) {
-  if (is_int($role)) {
-    $role = user_role_load($role);
-  }
-  else {
-    $role = user_role_load_by_name($role);
-  }
+function user_role_delete($role_name) {
+  $role = user_role_load($role_name);
 
   db_delete('role')
-    ->condition('rid', $role->rid)
+    ->condition('name', $role->name)
     ->execute();
   db_delete('role_permission')
-    ->condition('rid', $role->rid)
+    ->condition('role_name', $role->name)
     ->execute();
   // Update the users who have this role set:
   db_delete('users_roles')
-    ->condition('rid', $role->rid)
+    ->condition('role_name', $role->name)
     ->execute();
 
   module_invoke_all('user_role_delete', $role);
@@ -2972,7 +2952,7 @@ function user_role_delete($role) {
  */
 function user_role_edit_access($role) {
   // Prevent the system-defined roles from being altered or removed.
-  if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
+  if ($role->name == DRUPAL_ANONYMOUS_ROLE || $role->name == DRUPAL_AUTHENTICATED_ROLE) {
     return FALSE;
   }
 
@@ -3004,8 +2984,8 @@ function user_permission_get_modules() {
  * role, the form submit handler may directly pass the submitted values for the
  * checkboxes form element to this function.
  *
- * @param $rid
- *   The ID of a user role to alter.
+ * @param $role_name
+ *   The name of a user role to alter.
  * @param $permissions
  *   An associative array, where the key holds the permission name and the value
  *   determines whether to grant or revoke that permission. Any value that
@@ -3025,37 +3005,37 @@ function user_permission_get_modules() {
  * @see user_role_grant_permissions()
  * @see user_role_revoke_permissions()
  */
-function user_role_change_permissions($rid, array $permissions = array()) {
+function user_role_change_permissions($role_name, array $permissions = array()) {
   // Grant new permissions for the role.
   $grant = array_filter($permissions);
   if (!empty($grant)) {
-    user_role_grant_permissions($rid, array_keys($grant));
+    user_role_grant_permissions($role_name, array_keys($grant));
   }
   // Revoke permissions for the role.
   $revoke = array_diff_assoc($permissions, $grant);
   if (!empty($revoke)) {
-    user_role_revoke_permissions($rid, array_keys($revoke));
+    user_role_revoke_permissions($role_name, array_keys($revoke));
   }
 }
 
 /**
  * Grant permissions to a user role.
  *
- * @param $rid
- *   The ID of a user role to alter.
+ * @param $role_name
+ *   The name of a user role to alter.
  * @param $permissions
  *   A list of permission names to grant.
  *
  * @see user_role_change_permissions()
  * @see user_role_revoke_permissions()
  */
-function user_role_grant_permissions($rid, array $permissions = array()) {
+function user_role_grant_permissions($role_name, array $permissions = array()) {
   $modules = user_permission_get_modules();
   // Grant new permissions for the role.
   foreach ($permissions as $name) {
     db_merge('role_permission')
       ->key(array(
-        'rid' => $rid,
+        'role_name' => $role_name,
         'permission' => $name,
       ))
       ->fields(array(
@@ -3072,18 +3052,18 @@ function user_role_grant_permissions($rid, array $permissions = array()) {
 /**
  * Revoke permissions from a user role.
  *
- * @param $rid
- *   The ID of a user role to alter.
+ * @param $role_name
+ *   The name of a user role to alter.
  * @param $permissions
  *   A list of permission names to revoke.
  *
  * @see user_role_change_permissions()
  * @see user_role_grant_permissions()
  */
-function user_role_revoke_permissions($rid, array $permissions = array()) {
+function user_role_revoke_permissions($role_name, array $permissions = array()) {
   // Revoke permissions for the role.
   db_delete('role_permission')
-    ->condition('rid', $rid)
+    ->condition('role_name', $role_name)
     ->condition('permission', $permissions, 'IN')
     ->execute();
 
@@ -3112,7 +3092,7 @@ function user_user_operations($form = array(), $form_state = array()) {
 
   if (user_access('administer permissions')) {
     $roles = user_roles(TRUE);
-    unset($roles[DRUPAL_AUTHENTICATED_RID]);  // Can't edit authenticated role.
+    unset($roles[DRUPAL_AUTHENTICATED_ROLE]);  // Can't edit authenticated role.
 
     $add_roles = array();
     foreach ($roles as $key => $value) {
@@ -3141,14 +3121,14 @@ function user_user_operations($form = array(), $form_state = array()) {
   // If the form has been posted, we need to insert the proper data for
   // role editing if necessary.
   if (!empty($form_state['submitted'])) {
-    $operation_rid = explode('-', $form_state['values']['operation']);
-    $operation = $operation_rid[0];
+    $operation_role = explode('-', $form_state['values']['operation']);
+    $operation = $operation_role[0];
     if ($operation == 'add_role' || $operation == 'remove_role') {
-      $rid = $operation_rid[1];
+      $role_name = $operation_role[1];
       if (user_access('administer permissions')) {
         $operations[$form_state['values']['operation']] = array(
           'callback' => 'user_multiple_role_edit',
-          'callback arguments' => array($operation, $rid),
+          'callback arguments' => array($operation, $role_name),
         );
       }
       else {
@@ -3193,18 +3173,14 @@ function user_user_operations_block($accounts) {
 /**
  * Callback function for admin mass adding/deleting a user role.
  */
-function user_multiple_role_edit($accounts, $operation, $rid) {
-  // The role name is not necessary as user_save() will reload the user
-  // object, but some modules' hook_user() may look at this first.
-  $role_name = db_query('SELECT name FROM {role} WHERE rid = :rid', array(':rid' => $rid))->fetchField();
-
+function user_multiple_role_edit($accounts, $operation, $role_name) {
   switch ($operation) {
     case 'add_role':
       $accounts = user_load_multiple($accounts);
       foreach ($accounts as $account) {
         // Skip adding the role to the user if they already have it.
-        if ($account !== FALSE && !isset($account->roles[$rid])) {
-          $roles = $account->roles + array($rid => $role_name);
+        if ($account !== FALSE && !isset($account->roles[$role_name])) {
+          $roles = $account->roles + array($role_name => $role_name);
           // For efficiency manually save the original account before applying
           // any changes.
           $account->original = clone $account;
@@ -3216,8 +3192,8 @@ function user_multiple_role_edit($accounts, $operation, $rid) {
       $accounts = user_load_multiple($accounts);
       foreach ($accounts as $account) {
         // Skip removing the role from the user if they already don't have it.
-        if ($account !== FALSE && isset($account->roles[$rid])) {
-          $roles = array_diff($account->roles, array($rid => $role_name));
+        if ($account !== FALSE && isset($account->roles[$role_name])) {
+          $roles = array_diff($account->roles, array($role_name => $role_name));
           // For efficiency manually save the original account before applying
           // any changes.
           $account->original = clone $account;
@@ -3329,11 +3305,11 @@ function user_filters() {
   // Regular filters
   $filters = array();
   $roles = user_roles(TRUE);
-  unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role.
+  unset($roles[DRUPAL_AUTHENTICATED_ROLE]); // Don't list authorized role.
   if (count($roles)) {
     $filters['role'] = array(
       'title' => t('role'),
-      'field' => 'ur.rid',
+      'field' => 'ur.name',
       'options' => array(
         '[any]' => t('any'),
       ) + $roles,
@@ -3387,17 +3363,17 @@ function user_build_filter_query(SelectQuery $query) {
     if ($key == 'permission') {
       $account = new stdClass();
       $account->uid = 'user_filter';
-      $account->roles = array(DRUPAL_AUTHENTICATED_RID => 1);
+      $account->roles = array(DRUPAL_AUTHENTICATED_ROLE => DRUPAL_AUTHENTICATED_ROLE);
       if (user_access($value, $account)) {
         continue;
       }
       $users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
-      $permission_alias = $query->join('role_permission', 'p', $users_roles_alias . '.rid = %alias.rid');
+      $permission_alias = $query->join('role_permission', 'p', $users_roles_alias . '.role_name = %alias.role_name');
       $query->condition($permission_alias . '.permission', $value);
     }
     elseif ($key == 'role') {
       $users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
-      $query->condition($users_roles_alias . '.rid' , $value);
+      $query->condition($users_roles_alias . '.role_name' , $value);
     }
     else {
       $query->condition($filters[$key]['field'], $value);
@@ -3836,8 +3812,8 @@ function user_register_submit($form, &$form_state) {
  */
 function user_modules_installed($modules) {
   // Assign all available permissions to the administrator role.
-  $rid = variable_get('user_admin_role', 0);
-  if ($rid) {
+  $role_name = variable_get('user_admin_role', 0);
+  if ($role_name) {
     $permissions = array();
     foreach ($modules as $module) {
       if ($module_permissions = module_invoke($module, 'permission')) {
@@ -3845,7 +3821,7 @@ function user_modules_installed($modules) {
       }
     }
     if (!empty($permissions)) {
-      user_role_grant_permissions($rid, $permissions);
+      user_role_grant_permissions($role_name, $permissions);
     }
   }
 }
