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.
A quick fix is adding the following to the machine name field in role_export_form_alter():
'#required' => !empty($form_state['values']['name']),
No extensively tested though. (I've had an issue where the rids of the anonymous and authenticated user roles changed; not sure if it was related to above mentioned fix.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1370520-role-export-ordering.patch | 3.25 KB | klausi |
#7 | role_export_ordering-1370520-7.patch | 3.42 KB | Steven Brown |
#6 | 1370520-role-export-ordering.patch | 3.25 KB | klausi |
#2 | 1370520-role-export-ordering.patch | 1.72 KB | klausi |
Comments
Comment #1
Steven Brown CreditAttribution: Steven Brown commentedWhen re-arranging the order of the roles the default roles (anonymous, authenticated) are now assigned a new role id. I will look into the offending code base.
Comment #2
klausiHere is a patch that adds an exception for the anonymous and authenticated user roles to not alter them. Also fixes the role ordering form.
Please test!
Comment #3
Steven Brown CreditAttribution: Steven Brown commentedThis works for anonymous and authenticated just fine. However, the administrator role still gets a new id and we can't just simply add an OR id == 3 because administrator isn't always there. So should we do the following?
Comment #4
klausiBut I want my administrator role to get a role_export id! The problem is that the re-ordering triggers a role update. Maybe we can add a check to the update hook: if only the weight has changed do not generate the new id.
Comment #5
klausiThe problem is that we have no way to detect what was changed on the role. We could implement a custom submit callback and store the old role state in a global variable, but that would be more than ugly and could have other strange side effects.
Or we could just disallow role ordering while not all roles have a generated id.
Comment #6
klausiNew patch: Displays a warning on the roles page if there are old roles without machine name present. Also fixes a bug for saving roles without machine names.
Comment #7
Steven Brown CreditAttribution: Steven Brown commentedThe patch in #6 has a call to an undefined function 'role_export_role_add_form_validate' I am assuming this was just a mishap and needed to be changed to the validation function that was added for the roles form. This has been changed to 'role_export_roles_form_validate' in the provided patch. I've test and it works for me.
Comment #8
klausiAh, good catch (I experimented with other validation callbacks and obviously forgot to change it back).
You have '#required' twice in your patch, I removed the first one.
Otherwise works for me.
Comment #9
drakythe CreditAttribution: drakythe commentedSeems to work just fine.
Comment #10
Steven Brown CreditAttribution: Steven Brown commentedPatch from #8 has been tested and committed. http://drupalcode.org/project/role_export.git/commit/d7bff20