Problem/Motivation

There are currently a couple problems with the format of the exported configuration:

  1. Roles are not sorted This may create unnecessary diffs when committing the file into configuration
  2. 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
  3. 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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler created an issue. See original summary.

salvis’s picture

Status: Active » Postponed (maintainer needs more info)

I don't understand what you're referring to.

salvis’s picture

Status: Postponed (maintainer needs more info) » Needs work

Can we get a patch here?

nord102’s picture

I 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.

  • salvis committed 964e2e5 on 8.x-1.x authored by nord102
    Issue #2833688 by nord102: Filter and sort roles when saving config.
    
salvis’s picture

Status: Needs review » Fixed

Great, thank you, nord102!

Sorry about taking so long...

Status: Fixed » Closed (fixed)

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