Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.117
diff -u -p -r1.117 user.admin.inc
--- modules/user/user.admin.inc	1 Sep 2010 20:08:17 -0000	1.117
+++ modules/user/user.admin.inc	8 Sep 2010 06:07:31 -0000
@@ -860,10 +860,17 @@ function user_admin_roles($form, $form_s
  * Form submit function. Update the role weights.
  */
 function user_admin_roles_order_submit($form, &$form_state) {
+  $status = array();
   foreach ($form_state['values']['roles'] as $rid => $role_values) {
     $role = $form['roles'][$rid]['#role'];
     $role->weight = $role_values['weight'];
-    user_role_save($role);
+    $status[] = user_role_save($role);
+  }
+  if (in_array(FALSE, $status)) {
+    drupal_set_message(t('There is a problem in saving the form. Try later or contact site administrator'));
+  }
+  else {
+    drupal_set_message(t('The role settings have been updated.'));
   }
 }
 
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.101
diff -u -p -r1.101 user.test
--- modules/user/user.test	27 Aug 2010 11:28:45 -0000	1.101
+++ modules/user/user.test	8 Sep 2010 06:07:35 -0000
@@ -1588,7 +1588,7 @@ class UserRoleAdminTestCase extends Drup
   public static function getInfo() {
     return array(
       'name' => 'User role administration',
-      'description' => 'Test adding, editing and deleting user roles.',
+      'description' => 'Test adding, editing and deleting user roles and role weight change operations.',
       'group' => 'User',
     );
   }
@@ -1641,6 +1641,28 @@ class UserRoleAdminTestCase extends Drup
     $this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_AUTHENTICATED_RID);
     $this->assertResponse(403, t('Access denied when trying to edit the built-in authenticated role.'));
   }
+
+  /**
+   * Test user role weight change operation.
+   */
+  function testRoleWeightChange() {
+    $this->drupalLogin($this->admin_user);
+
+    // Pick up a rand role and get its weight.
+    $rid = array_rand(user_roles());
+    $role = user_role_load($rid);
+    $old_weight = $role->weight;
+
+    // Change the role weight and submit the form.
+    $edit = array('roles['. $rid .'][weight]' => $old_weight + 1);
+    $this->drupalPost('admin/people/permissions/roles', $edit, t('Save order'));
+    $this->assertText(t('The role settings have been updated.'), t('The role settings form submitted successfully.'));
+
+    // Retrive the saved role and compare its weight.
+    $role = user_role_load($rid);
+    $new_weight = $role->weight;
+    $this->assertTrue(($old_weight + 1) == $new_weight, t('Role weight updated successfully.'));
+  }
 }
 
 /**
