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.

CommentFileSizeAuthor
#2 2908729-2.patch846 bytesmikran
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikran created an issue. See original summary.

mikran’s picture

Status: Active » Needs review
FileSize
846 bytes

trivial patch

mo6’s picture

Patch works perfectly.

mo6’s picture

Status: Needs review » Reviewed & tested by the community
kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Needs work

$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

Anna Godura’s picture

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

ronaldtebrake’s picture

Status: Needs work » Closed (cannot reproduce)

I’ve tested the above scenario with members and outsiders, in a hook_preprocess_group to see what happens with

$group->hasPermission($permission, $account);

Can’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.