Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Warning: Invalid argument supplied for foreach() in Drupal\group\Entity\Storage\GroupRoleStorage->loadByUserAndGroup() (line 96 of modules/contrib/group/src/Entity/Storage/GroupRoleStorage.php).
that is the error I get by asking a group if user hasPermission
.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2908729-2.patch | 846 bytes | mikran |
|
Comments
Comment #2
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedtrivial patch
Comment #3
mo6Patch works perfectly.
Comment #4
mo6Comment #5
kristiaanvandeneynde$membership->getGroupContent()->group_roles should always return an Drupal\Core\Field\EntityReferenceFieldItemList which is perfectly fine to pull through a foreach loop seeing as it implements IteratorAggregate.
Can you please provide a scenario in which this error can be reproduced? Preferably on simplytest.me
Comment #6
Anna Godura CreditAttribution: Anna Godura commentedI am getting this same error. I did a var_dump of group_roles and it is null, though I don't know why, since the user is the group creator.
Comment #7
ronaldtebrake CreditAttribution: ronaldtebrake as a volunteer and for Open Social commentedI’ve tested the above scenario with members and outsiders, in a
hook_preprocess_group
to see what happens withCan’t seem to reproduce it under any circumstances.
Please open up a new ticket with a scenario in which this error can be reproduced if this is still an issue.