Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Adding a machine name to the administrator role leads to a change in the role id, but the according 'user_admin_role' variable doesn't get updated, which then causes some problems on the website.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1334030-role-export-admin-var.patch | 1.65 KB | klausi |
#3 | 1334030-role-export-admin-var.patch | 777 bytes | klausi |
#1 | 1334030-role-export-admin-var.patch | 826 bytes | klausi |
Comments
Comment #1
klausiSimple patch attached.
Comment #2
Steven Brown CreditAttribution: Steven Brown commentedKlausi, please re-roll the patch. I committed the changes from issue #1333048 so the patch doesn't work against the current code base.
Comment #3
klausiReroll.
Comment #4
mh86 CreditAttribution: mh86 commentedno, patch from #3 doesn't solve the problem.
This needs to be fixed in hook_user_role_insert as well, as in hook_user_role_update the check with $role->rid == variable_get('user_admin_role') will always fail, if the admin role has been inserted while the role export module was already enabled (then $role->rid has the generated id, admin role the original one).
Comment #5
mh86 CreditAttribution: mh86 commentedComment #6
klausiI don't understand - if a role is inserted and has not existed before, how can user_admin_role be already set to this role?
And of course you can fix your admin role manually on the user account settings page.
Comment #7
mh86 CreditAttribution: mh86 commentedIf you do something like this (which happens in the standard install profile)
Then $admin_role->rid unfortunately still has the old role id.
Comment #8
klausiAh, now I get it. We need to set the new id in the role object. And we should make sure that role_export hooks run first, so that other modules get the new role id. Patch attached.
Comment #9
mh86 CreditAttribution: mh86 commentedPatch from #8 works now. Thanks for taking a look at it.
Comment #10
klausiCommitted, see http://drupalcode.org/project/role_export.git/commit/c8f70c5