diff options
author | David Rothstein <drothstein@gmail.com> | 2015-10-03 14:53:43 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2015-10-03 14:53:43 -0400 |
commit | 47d24ed171bcb4c6aca409ce8af0844a06520f5c (patch) | |
tree | 331429ceb5255bd47c0c342d642633db8a7eb926 /modules | |
parent | e575b47da2f00016ee62d169ecdfaf09e8cb4cd5 (diff) | |
download | brdo-47d24ed171bcb4c6aca409ce8af0844a06520f5c.tar.gz brdo-47d24ed171bcb4c6aca409ce8af0844a06520f5c.tar.bz2 |
Issue #2364629 by gaurav.goyal, cilefen, dcam: After deletion of built-in administrator role the default admin role is not shown as disabled
Diffstat (limited to 'modules')
-rw-r--r-- | modules/user/user.module | 5 | ||||
-rw-r--r-- | modules/user/user.test | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index 9637a7165..21a41d56f 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -3039,6 +3039,11 @@ function user_role_delete($role) { $role = user_role_load_by_name($role); } + // If this is the administrator role, delete the user_admin_role variable. + if ($role->rid == variable_get('user_admin_role')) { + variable_del('user_admin_role'); + } + db_delete('role') ->condition('rid', $role->rid) ->execute(); diff --git a/modules/user/user.test b/modules/user/user.test index 07be4c2c4..97d23b44c 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -2095,12 +2095,16 @@ class UserRoleAdminTestCase extends DrupalWebTestCase { $this->assertFalse(user_role_load_by_name($old_name), 'The role can no longer be retrieved from the database using its old name.'); $this->assertTrue(is_object(user_role_load_by_name($role_name)), 'The role can be retrieved from the database using its new name.'); - // Test deleting a role. + // Test deleting the default administrator role. + $role_name = 'administrator'; + $role = user_role_load_by_name($role_name); $this->drupalPost("admin/people/permissions/roles/edit/{$role->rid}", NULL, t('Delete role')); $this->drupalPost(NULL, NULL, t('Delete')); $this->assertText(t('The role has been deleted.'), 'The role has been deleted'); $this->assertNoLinkByHref("admin/people/permissions/roles/edit/{$role->rid}", 'Role edit link removed.'); $this->assertFalse(user_role_load_by_name($role_name), 'A deleted role can no longer be loaded.'); + // Make sure this role is no longer configured as the administrator role. + $this->assertNull(variable_get('user_admin_role'), 'The administrator role is no longer configured as the administrator role.'); // Make sure that the system-defined roles cannot be edited via the user // interface. |