Problem/Motivation
The permissions for a Group Type cannot be saved without triggering an uncaught exception error
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\group\Entity\GroupRole::changePermissions() must be of the type array, null given, called in /app/docroot/modules/contrib/group/src/Form/GroupPermissionsForm.php on line 310 in Drupal\group\Entity\GroupRole->changePermissions() (line 272 of modules/contrib/group/src/Entity/GroupRole.php).
Steps to reproduce
- Install Group 2.0 then log-in to Drupal as an Administrator and enable Group
- Create a new Group type at /admin/group/types/add
- Check the option Automatically configure an administrative role to enabled
- Click the button Save group type
- From the Group Types list at /admin/group/types use the operation Edit permissions for the Group Type just created
- On the Group Type permissions form click the button Save permissions
This will generate an HTTP 500 error
The website encountered an unexpected error. Please try again later.
Logging or displaying the uncaught exception
TypeError: Argument 1 passed to Drupal\group\Entity\GroupRole::changePermissions() must be of the type array, null given, called in /app/docroot/modules/contrib/group/src/Form/GroupPermissionsForm.php on line 310 in Drupal\group\Entity\GroupRole->changePermissions() (line 272 of modules/contrib/group/src/Entity/GroupRole.php).
Proposed resolution
When submitting and saving Group Type permissions skip the special "Admin" group type as it is not included in the form.
Remaining tasks
Write tests?
User interface changes
None
API changes
None
Data model changes
None
Issue fork group-3281530
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
chop commentedComment #4
chop commentedDowngrading from "Critical" priority to "Major" as most role permissions do seem to save in spite of the error. The Admin group role is last to be processed, so the error triggers after most other group roles are saved.
Comment #5
kristiaanvandeneyndeThanks for the bug report, fix looks good. The whole permissions form isn't properly tested it seems, so we might want to add a follow-up task for that.