Problem/Motivation
I tried enabling the realname module in a website already running for some years now in production. In this website there are already lots of users, custom templates and at the same time its whole functionality is heavily based on Group module.
After enabling the module, the website started displaying the following error log (attached in full detail):
TypeError: Drupal\group\Entity\Storage\GroupRoleStorage::loadByUserAndGroup(): Argument #1 ($account) must be of type Drupal\Core\Session\AccountInterface, null given, called in /var/www/html/web/modules/contrib/group/src/Entity/GroupMembershipTrait.php on line 41 in Drupal\group\Entity\Storage\GroupRoleStorage->loadByUserAndGroup() (line 81 of modules/contrib/group/src/Entity/Storage/GroupRoleStorage.php).
Drupal\group\Entity\GroupMembership->getRoles() (Line: 90)
Drupal\group\GroupMembership->getRoles() (Line: 64)
Drupal\group\Access\IndividualGroupPermissionCalculator->calculatePermissions() (Line: 138)
Steps to reproduce
N/A
Proposed resolution
Return an empty array if $this->getEntity() returns a faulty value.
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #3
vensiresAdding patch based on MR!300.
PS: In case it helps in the general context, after addressing this issue, the bug described in #3593343: Prohibit accidental twig recursion appeared.