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.
Problem/Motivation
There are currently a couple problems with the format of the exported configuration:
- Roles are not sorted This may create unnecessary diffs when committing the file into configuration
- Unused roles are saved into the configuration Because this is just a simple configuration and not a config entity, this is not such a big issue, but it's still not nice
- Role names are duplicated Not a real big issue either, but would still be nice to fix
Proposed resolution
I think instead of just saving the raw form values to configuration, it would be better to save:
$values = array_keys(array_filter($form_values));
sort($values);
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#4 | roleassign-filter_and_sort_roles_when_saving_config-2833688-4.patch | 860 bytes | nord102 |
|
Comments
Comment #2
salvisI don't understand what you're referring to.
Comment #3
salvisCan we get a patch here?
Comment #4
nord102I have attached a patch that, based on the proposed resolution, runs the roleassign_roles form_state value through array_filter() to remove all unchecked roles, array_keys() to only grab the keys to prevent the duplication of role names, and then sort() to get the roles sorted alphabetically.
I believe that all of these make the roleassign config closer to the convention used in other configuration.
Comment #6
salvisGreat, thank you, nord102!
Sorry about taking so long...