Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.423 diff -u -p -r1.423 bootstrap.inc --- includes/bootstrap.inc 7 Oct 2010 03:35:03 -0000 1.423 +++ includes/bootstrap.inc 7 Oct 2010 18:56:40 -0000 @@ -180,12 +180,12 @@ define('DRUPAL_BOOTSTRAP_FULL', 7); /** * Role ID for anonymous users; should match what's in the "role" table. */ -define('DRUPAL_ANONYMOUS_RID', 1); +define('DRUPAL_ANONYMOUS_RID', 'anonymous'); /** * Role ID for authenticated users; should match what's in the "role" table. */ -define('DRUPAL_AUTHENTICATED_RID', 2); +define('DRUPAL_AUTHENTICATED_RID', 'authenticated'); /** * The number of bytes in a kilobyte. For more information, visit Index: modules/block/block.install =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.install,v retrieving revision 1.46 diff -u -p -r1.46 block.install --- modules/block/block.install 28 Sep 2010 03:30:37 -0000 1.46 +++ modules/block/block.install 7 Oct 2010 19:17:04 -0000 @@ -119,9 +119,9 @@ function block_schema() { 'description' => "The block's unique delta within module, from {block}.delta.", ), 'rid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, 'description' => "The user's role ID from {users_roles}.rid.", ), ), @@ -445,6 +445,26 @@ function block_update_7006() { } /** + * Change {block_role}.rid into varchar. + */ +function block_update_7007() { + db_change_field('block_role', 'rid', 'rid', array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + 'description' => "The user's role ID from {users_roles}.rid.", + )); + db_update('block_role') + ->fields(array('rid' => 'anonymous')) + ->condition('rid', 1) + ->execute(); + db_update('block_role') + ->fields(array('rid' => 'authenticated')) + ->condition('rid', 2) + ->execute(); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/contact/contact.install =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v retrieving revision 1.25 diff -u -p -r1.25 contact.install --- modules/contact/contact.install 8 Jun 2010 03:48:14 -0000 1.25 +++ modules/contact/contact.install 7 Oct 2010 18:59:17 -0000 @@ -121,7 +121,8 @@ function contact_update_7002() { // disabled. db_merge('role_permission') ->key(array( - 'rid' => DRUPAL_AUTHENTICATED_RID, + // 2 == DRUPAL_AUTHENTICATED_RID + 'rid' => 2, 'permission' => 'access user contact forms', 'module' => 'contact', )) Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.240 diff -u -p -r1.240 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 5 Oct 2010 06:17:29 -0000 1.240 +++ modules/simpletest/drupal_web_test_case.php 8 Oct 2010 04:15:01 -0000 @@ -1040,6 +1040,7 @@ class DrupalWebTestCase extends DrupalTe // Create new role. $role = new stdClass(); + $role->rid = drupal_strtolower($name); $role->name = $name; user_role_save($role); user_role_grant_permissions($role->rid, $permissions); Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.515 diff -u -p -r1.515 system.install --- modules/system/system.install 6 Oct 2010 13:38:40 -0000 1.515 +++ modules/system/system.install 7 Oct 2010 18:59:15 -0000 @@ -2101,7 +2101,8 @@ function system_update_7027() { function system_update_7029() { db_insert('role_permission') ->fields(array( - 'rid' => DRUPAL_AUTHENTICATED_RID, + // 2 == DRUPAL_AUTHENTICATED_RID + 'rid' => 2, 'permission' => 'view own unpublished content', )) ->execute(); Index: modules/user/user.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v retrieving revision 1.119 diff -u -p -r1.119 user.admin.inc --- modules/user/user.admin.inc 6 Oct 2010 13:38:40 -0000 1.119 +++ modules/user/user.admin.inc 7 Oct 2010 19:24:00 -0000 @@ -847,6 +847,11 @@ function user_admin_roles($form, $form_s '#size' => 32, '#maxlength' => 64, ); + $form['rid'] = array( + '#type' => 'textfield', // @todo http://drupal.org/node/902644 + '#required' => TRUE, + '#maxlength' => 64, + ); $form['add'] = array( '#type' => 'submit', '#value' => t('Add role'), @@ -891,13 +896,13 @@ function theme_user_admin_roles($variabl $name = $form['roles'][$rid]['#role']->name; $row = array(); if (in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - $row[] = t('@name (locked)', array('@name' => $name)); + $row[] = t('@name (locked) (Machine name: @rid)', array('@name' => $name, '@rid' => $rid)); $row[] = drupal_render($form['roles'][$rid]['weight']); $row[] = ''; $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid); } else { - $row[] = check_plain($name); + $row[] = t('@name (Machine name: @rid)', array('@name' => $name, '@rid' => $rid)); $row[] = drupal_render($form['roles'][$rid]['weight']); $row[] = l(t('edit role'), 'admin/people/permissions/roles/edit/' . $rid); $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid); @@ -937,8 +942,11 @@ function user_admin_role($form, $form_st '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'), ); $form['rid'] = array( - '#type' => 'value', + '#type' => 'textfield', // @todo http://drupal.org/node/902644 + '#required' => TRUE, + '#maxlength' => 64, '#value' => $role->rid, + '#disabled' => TRUE, ); $form['weight'] = array( '#type' => 'value', Index: modules/user/user.install =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.install,v retrieving revision 1.67 diff -u -p -r1.67 user.install --- modules/user/user.install 5 Oct 2010 06:17:29 -0000 1.67 +++ modules/user/user.install 7 Oct 2010 19:16:28 -0000 @@ -56,9 +56,9 @@ function user_schema() { 'description' => 'Stores the permissions assigned to user roles.', 'fields' => array( 'rid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, 'description' => 'Foreign Key: {role}.rid.', ), 'permission' => array( @@ -92,9 +92,9 @@ function user_schema() { 'description' => 'Stores user roles.', 'fields' => array( 'rid' => array( - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, 'description' => 'Primary Key: Unique role ID.', ), 'name' => array( @@ -259,10 +259,9 @@ function user_schema() { 'description' => 'Primary Key: {users}.uid for user.', ), 'rid' => array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, 'description' => 'Primary Key: {role}.rid for role.', ), ), @@ -314,27 +313,11 @@ function user_install() { // Built-in roles. $rid_anonymous = db_insert('role') - ->fields(array('name' => 'anonymous user', 'weight' => 0)) + ->fields(array('rid' => 'anonymous', 'name' => 'anonymous user', 'weight' => 0)) ->execute(); $rid_authenticated = db_insert('role') - ->fields(array('name' => 'authenticated user', 'weight' => 1)) + ->fields(array('rid' => 'authenticated', 'name' => '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(); - } } /** @@ -838,6 +821,40 @@ function user_update_7014() { } /** + * Change all .rid columns in user schema to varchar. + */ +function user_update_7015() { + db_change_field('role_permission', 'rid', 'rid', array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + 'description' => 'Foreign Key: {role}.rid.', + )); + db_change_field('role', 'rid', 'rid', array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + 'description' => 'Primary Key: Unique role ID.', + )); + db_change_field('users_roles', 'rid', 'rid', array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => FALSE, + 'description' => 'Primary Key: {role}.rid for role.', + )); + foreach (array('role_permission', 'role', 'users_roles') as $table) { + db_update($table) + ->fields(array('rid' => 'anonymous')) + ->condition('rid', 1) + ->execute(); + db_update($table) + ->fields(array('rid' => 'authenticated')) + ->condition('rid', 2) + ->execute(); + } +} + +/** * @} End of "defgroup user-updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1206 diff -u -p -r1.1206 user.module --- modules/user/user.module 4 Oct 2010 14:54:10 -0000 1.1206 +++ modules/user/user.module 8 Oct 2010 01:24:25 -0000 @@ -2743,7 +2743,8 @@ function user_role_save($role) { $query->addExpression('MAX(weight)'); $role->weight = $query->execute()->fetchField() + 1; } - if (!empty($role->rid) && $role->name) { + $exists = db_query_range('SELECT 1 FROM {role} WHERE rid = :rid', 0, 1, array(':rid' => $role->rid))->fetchField(); + if ($exists) { $status = drupal_write_record('role', $role, 'rid'); module_invoke_all('user_role_update', $role); } Index: profiles/standard/standard.install =================================================================== RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v retrieving revision 1.26 diff -u -p -r1.26 standard.install --- profiles/standard/standard.install 5 Oct 2010 06:17:29 -0000 1.26 +++ profiles/standard/standard.install 8 Oct 2010 01:21:38 -0000 @@ -405,6 +405,7 @@ function standard_install() { // Create a default role for site administrators, with all available permissions assigned. $admin_role = new stdClass(); + $admin_role->rid = 'administrator'; $admin_role->name = 'administrator'; $admin_role->weight = 2; user_role_save($admin_role);