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

  1. Install Group 2.0 then log-in to Drupal as an Administrator and enable Group
  2. Create a new Group type at /admin/group/types/add
  3. Check the option Automatically configure an administrative role to enabled
  4. Click the button Save group type
  5. From the Group Types list at /admin/group/types use the operation Edit permissions for the Group Type just created
  6. 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

Command icon 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

chOP created an issue. See original summary.

chop’s picture

Status: Active » Needs review
chop’s picture

Title: Cannot save Group Type permissions with an administrative role enabled » Error saving Group Type permissions with administrative role enabled
Priority: Critical » Major

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

kristiaanvandeneynde’s picture

Status: Needs review » Fixed

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

Status: Fixed » Closed (fixed)

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