Renaming a role currently causes the loss of role_delegation permissions for that role.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Christefano-oldaccount’s picture

Does this mean that Role Delegation isn't using role IDs?

David Lesieur’s picture

The problem is that the permission names created by Role Delegation are derived from role names, and Drupal uses permissions names as IDs. Using role IDs is not an option here, as that would make the Access control settings unusable.

Something we could probably do is updating the permissions when the role editing form ("user_admin_role") is submitted.

Andrew Schulman’s picture

Version: 5.x-1.0 » 6.x-1.2
Status: Active » Needs review
FileSize
2.29 KB

Something we could probably do is updating the permissions when the role editing form ("user_admin_role") is submitted.

The attached patch does this. When role X is renamed or deleted, we rename or delete (resp.) the "assign X role" permission in every entry in the permission table. Please test.

Andrew Schulman’s picture

David, do you plan to merge this patch? Do you think it's too complex, or the problem not common enough to be worth fixing? Or have you just not gotten to test it?

I tested the patch at the time I wrote it, and it worked fine. I haven't tested it lately, but I can do so again, and update it against the latest CVS.

The reason I ask now is that D7 will be out soon, and role delegation has a working D7 port. I could port this patch to D7 too, but I don't see any benefit to doing that if you don't plan to merge it.

Thanks,
Andrew.

David Lesieur’s picture

I think the patch would be a good thing, but have not tested it yet. (sorry!)

Andrew Schulman’s picture

Version: 6.x-1.2 » 6.x-1.3
FileSize
2.41 KB

OK, I remade the patch against current D6 CVS. Here it is.

I tested it again and it works fine. Permissions are renamed and deleted when roles are renamed and deleted. Could someone else please also test it?

  • If you rename a role, then go to admin/user/permissions, you should see the "assign $role permission" permission renamed, and every role that had that permission before should still have it, indicating that their entries in the permission table were correctly updated with the new name.
  • If you delete a role, the "assign $role permission" permission will go away. If you then recreate that role, the permission will return, but roles that used to have that permission should no longer have it, because it was deleted from their entries in the permission table.

D7 has a new API for managing roles. I'll port the patch to that as I have time.

Andrew Schulman’s picture

A simple test case, labeled "Role editing", has been added in D7, to test whether this works. So far it doesn't, since the patch above hasn't been ported to D7 yet.

Andrew Schulman’s picture

Status: Needs review » Fixed

Fixed in D6 and D7 -dev branches. D7 branch now passes the "Role editing" simple tests, confirming that "assign role" permissions are being correctly renamed or deleted when roles are renamed or deleted.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.