Problem with Drupal 9 compatibility
Thanks for creating this module! It looks great though we have some issues with it. :-)
The module doesn't work as it is now with Drupal 9.
Trying to add an user to the group produces the following error:
messageNotice: Undefined index: handler_settings in Drupal\group_roles_management\Plugin\EntityReferenceSelection\GroupTypeRoleSelection->buildEntityQuery() (line 28 of modules/contrib/group_roles_management/src/Plugin/EntityReferenceSelection/GroupTypeRoleSelection.php).
You can fix this by changing the following:
$group_type_id = $this->configuration['handler_settings']['group_type_id'];
to:
$group_type_id = $this->configuration['group_type_id'];
But fixing that, another error pops up:
Error: Call to a member function getTranslationFromContext() on null in Drupal\group_roles_management\Plugin\EntityReferenceSelection\GroupTypeRoleSelection->getReferenceableEntities() (line 76 of modules/contrib/group_roles_management/src/Plugin/EntityReferenceSelection/GroupTypeRoleSelection.php).
And even after fixing that, there are issues with setting the roles.
If you get the correct role listing to display in the group member edit screen, there will be an issue with the following workflow:
- Create a group with two roles "Editor" and "Admin"
- Allow Editor role to manage the Editor-role but not Admin
- Now edit an user who has the Admin role (you won't see the user having an admin role) and hit save
- That user now doesn't have the Admin-role anymore because the save just stored the values in the form.
Problem with existing groups
After enabling this module, you can edit the role permissions for existing groups but these aren't stored in the correct format in the backend somehow. So you see your role based permissions in the Group Type Permissions screen but whenever you call functions like $group->hasPermission("manage members with role {$role_id}", $account) they will always return false for existing groups.
If you add a new group, there are no issues with this.
Issue fork group_roles_management-3181094
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 #2
j-vee commentedComment #3
lobsterr commentedComment #5
lobsterr commented@j-vee
Please review a PR
1) Fixed "messageNotice: Undefined index: handler_settings in "
2) Fixed "Error: Call to a member function getTranslationFromContext() on null in "
3) Fixed the bug, when we have user with multiple roles. Now we keep all the roles to which a user doesn't have access
4) The last issue "Problem with existing groups". Unfortunately, I can't reproduce. Are you sure you set correctly rights and you check the correct role.
Comment #6
j-vee commentedAnd I can't reproduce my second issue anymore. Fixing these issues seems to have remedied that problem as well so in my books, this is all good!
Comment #7
j-vee commentedSorry, I spoke too soon!
Continuing on with my other dev work with this update installed, I ran into the following issue when I tried to add a Node to a Group:
And trying to add a new group brings about this error:
Drupal\Core\Entity\EntityStorageException: Field group_roles is unknown. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).Any ideas?
Comment #8
lobsterr commentedWhat a rookie mistake. My bad. I will fix it soon
Comment #9
lobsterr commentedIt should be fixed
Comment #10
j-vee commentedCan't find any errors with the latest code :-) Thanks for your quick reaction, works really well!
Comment #12
lobsterr commented@J-vee Thanks for your help