Problem/Motivation
* When a helper module of mine does a $role->revokePermission('foo'),
* and i do a config export,
* i get a diff like this (note the missing '3' index)
diff --git a/config-sync/user.role.toggle_all.yml b/config-sync/user.role.toggle_all.yml
index 0ce46a0..35ac270 100644
--- a/config-sync/user.role.toggle_all.yml
+++ b/config-sync/user.role.toggle_all.yml
@@ -7,11 +7,10 @@ label: 'Toggle all'
weight: -2
is_admin: null
permissions:
- - 'abstractpermissions:role_toggle:toggle_all'
- - 'access administration pages'
- - 'access toolbar'
- - 'role_toggle:administrator'
- - 'role_toggle:debugger'
- - 'role_toggle:design_manager'
- - 'role_toggle:site_manager'
- - 'role_toggle:translation_manager'
+ 0: 'abstractpermissions:role_toggle:toggle_all'
+ 1: 'access administration pages'
+ 2: 'access toolbar'
+ 4: 'role_toggle:debugger'
+ 5: 'role_toggle:design_manager'
+ 6: 'role_toggle:site_manager'
+ 7: 'role_toggle:translation_manager'
When i then re-add it, i get:
diff --git a/config-sync/user.role.toggle_all.yml b/config-sync/user.role.toggle_all.yml
index 0ce46a0..8cb0074 100644
--- a/config-sync/user.role.toggle_all.yml
+++ b/config-sync/user.role.toggle_all.yml
@@ -10,8 +10,8 @@ permissions:
- 'abstractpermissions:role_toggle:toggle_all'
- 'access administration pages'
- 'access toolbar'
- - 'role_toggle:administrator'
- 'role_toggle:debugger'
- 'role_toggle:design_manager'
- 'role_toggle:site_manager'
- 'role_toggle:translation_manager'
+ - 'role_toggle:administrator'
Proposed resolution
In \Drupal\user\Entity\Role::preSave, add the missing array_values to the normilization.
Ex. 2 above shows that neither index normalization nor sorting work reliably.
\Drupal\user\Entity\Role::preSave:
if (!$this->isSyncing()) {
// Permissions are always ordered alphabetically to avoid conflicts in the
// exported configuration.
sort($this->permissions);
}
Remaining tasks
Doit
User interface changes
None
API changes
None
Data model changes
None