- First commit to issue fork.
- πΊπΈUnited States audioroger Bristol, VT
I had a similar experience when renaming, disabling or deleting a custom permission. Any of these actions leads to an exception when saving the permissions from /admin/people/permissions.
RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "[permission-name]". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of core/modules/user/src/Entity/Role.php).
The workaround I found was to first disable the custom permission for all user roles and save. Then rename, disable or delete the custom permission. In the case that you are renaming, you would then go back to the permissions page and re-enable the permission for the roles you removed it from.
Note: I have no idea how this works with translations.
More explicitly
Steps to reproduce
- Login as an Administrator
- Go to: /admin/people/custom-permissions/list
- Add a permission and save
- Open a new tab and go to: /admin/people/permissions
- Search for the custom permission added in step 3
- Enable it for any role below Administrator and save permissions
- Go back to: /admin/people/custom-permissions/list
- Rename, disable or delete the permission added in step 3 and save
- Go back to: /admin/people/permissions
- With no changes: Scroll down and click "Save permissions"
Behavior
Exception shown above
Expected Behavior
Permissions save without exception
Workaround
- Login as an Administrator
- Go to: /admin/people/custom-permissions/list
- Add a permission and save
- Open a new tab and go to: /admin/people/permissions
- Search for the permission from step 3
- Disable it for ALL ROLES below Administrator and save permissions
- Go back to: /admin/people/custom-permissions/list
- Disable, rename or delete the permission(s) from step 3 and save
- Go back to: /admin/people/permissions
- With no changes: Scroll down and click "Save permissions"
In the case of renaming the permission, re-enable it for all roles in step 9/10
Behavior
Permissions save without exception
Environment
Drupal core: 10.2.8
config_perms: 2.1.0