Error: Call to a member function getPluginId() on null in modules/contrib/group/src/Entity/Storage/GroupRelationshipStorage.php on line 93

Created on 6 November 2023, about 1 year ago

Problem/Motivation

For some unknown issue, we get a fatal error after upgrading from 1.6 to 2.2.1. The error occurs when trying to reinstall the site locally after the upgrade... The installation fails during the config import step.
Error: Call to a member function getPluginId() on null in modules/contrib/group/src/Entity/Storage/GroupRelationshipStorage.php on line 93
While debugging it, I see that the value of the $bundle is "group_content"

Steps to reproduce

I couldn't reproduce it on a clean drupal installation. However, in our website we have search_api index that indexes the group memberships. When removing all fields from the index, we no longer get the error!

Proposed resolution

Check the existence of the group_content_type.

πŸ› Bug report
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium msnassar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @msnassar
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9,625 pass, 2 fail
  • πŸ‡§πŸ‡ͺBelgium msnassar

    Patch for group 3

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9,628 pass
  • Status changed to Postponed: needs info 11 months ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Meta-review: Posting patch / MR without setting NR or explanation what you do will not get you good karma.

    Please check if it's a dup of the other issue.

  • Status changed to Needs review 11 months ago
  • πŸ‡§πŸ‡ͺBelgium msnassar

    Sorry forgot to change to NR.
    I have updated the description of the ticket to have better explanation for the issue and added UPDATE section too...

  • πŸ‡ΈπŸ‡³Senegal diaodiallo

    Hi, I am having this same issue with 2.2 but patch 2 is not working. Do someone fix this on 2.2?

  • Status changed to RTBC 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States dww

    Hrm, I ran into exactly this error when trying to deploy some new config from local to a public test site that included creating some new group types and associated fields. drupal/group is at 3.2.2. Patch #4 allows the config import to succeed and I haven't noticed any trouble (although there's no site-specific test coverage yet).

    It definitely looks like @kristiaanvandeneynde prefers patches, since there's neither a .gitlab-ci.yml file nor an issue about adding one. πŸ˜‚ Alas, patches aren't going to be tested in a few weeks/months. So we probably need to start moving everything to MRs, but that doesn't have to happen here. See πŸ“Œ Add .gitlab-ci.yml file for automated MR testing Active

    The resulting proposed code in src/Entity/Storage/GroupRelationshipStorage.php is a little dense, but that's mostly due to having to deal with both $group_relationship_type and $group_relation_type and needing to understand the difference. But that's part of working with the Group API. πŸ˜… Most of the patch bytes are due to adding a level of indentation for a new if, not actual changes.

    Re: #6: #3414592 was created after this issue, so if anything, that one would be duplicate with this. To me, the code makes more sense in this patch than in https://git.drupalcode.org/project/group/-/merge_requests/125 (which contains CS errors, although we wouldn't know that until #3426239 is done).

    I'm only supposed to be maintaining legacy branches, so I don't feel comfortable committing this. But I'll move it to RTBC and assign.

    Thanks!
    -Derek

  • Status changed to Needs work 10 months ago
  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    I've never been a fan of code that hides symptoms rather than fights the cause or at least documents why we're hiding the symptoms instead. Some people call that defensive coding, I call that an invitation to go unnecessarily deep down a rabbit hole when you eventually end up having to debug all these hidden symptoms.

    As the IS mentions, the OP cannot reproduce this on a clean installation so we don't even know if there is a bug in Group to begin with. If someone could come up with a reproducible way to trigger this error, either through instructions or (better yet) an automated test, then we could properly investigate this.

    As far as #9 goes: I appreciate you not committing anything to the newer branches. As I've explained on the other issue regarding GitLab CI, I do prefer MRs, but they have to be made against 3.3.x, after which I'll backport them to 2.3.x. Older minor versions do not see any updates once a new one is out.

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States dww

    All great points in #10. Agreed that better understanding the cause and having tests are needed before this is commit-able. Tagging and unassigning. Apologies for being hasty. I was coming to this issue from this story / experience:

    It's late, I'm finally deploying another version of the site for a new round of user testing that everyone's excited about. I've got the tagged release up on the test site, but drush cim is dying with a fatal error in GroupRelationshipStorage. Ugh, WTF? Search issue queue. There's exactly the error message I'm seeing. There's a patch. Looks pretty reasonable. Try it. It works. I can proceed with sending out that email to all the user testers. Lemme see if I can move this along as a real upstream fix...

    I was not thinking like a maintainer, more like a consumer. Sorry for that!

    I can probably work on a test for this, since I have a reproducible situation locally. I haven't properly gone down the rabbit hole, yet, but my hunch is that some group-related config is not declaring its dependencies fully, and on config import, we're trying to create a group before the corresponding group_relationship_type exists. Anyway, I'll report back once I actually have a chance to debug this. Immediate need is to make progress on other fronts now that I have a work-around for this one. πŸ˜…

    Sorry for the confusion around GitLab CI. I'll reply there.

    Totally agreed on not committing anything to newer branches. That was our agreement all along. I was documenting it for the other participants here. I should have said "have agreed not to" instead of "don't feel comfortable". Again, sorry for the late night sloppy writing.

    Thanks!
    -Derek

  • πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

    Yeah no worries. In general I'll never commit code that hides symptoms, it's just kicking the can down the road and will eventually catch up with you with all sorts of unpleasantries.

  • πŸ‡ΊπŸ‡ΈUnited States xyxxznpm

    Applying patch #4 for group version 3.2.2, error fixed. Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States dalemoore

    I'm running into this issue after just installing Group. Tried to go and create my first group following the docs and immediately get the error. And now I get it any time I go to /admin/group.

    The website encountered an unexpected error. Try again later.
    
    Error: Call to a member function getPluginId() on null in Drupal\group\Entity\Storage\GroupRelationshipStorage->getEntityClass() (line 93 of modules/contrib/group/src/Entity/Storage/GroupRelationshipStorage.php).
    
    Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('group_relationship', 'microsite-group_membership', Array) (Line: 353)
    Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('group_relationship', 'microsite-group_membership') (Line: 1219)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables(Array, ) (Line: 503)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords(Array) (Line: 428)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage(Array) (Line: 394)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple(Array) (Line: 312)
    Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 84)
    Drupal\group\Entity\GroupMembership::loadByUser(Object, NULL) (Line: 68)
    Drupal\group\GroupMembershipLoader->loadByUser(Object) (Line: 58)
    Drupal\group\Access\IndividualGroupPermissionCalculator->calculatePermissions(Object, 'individual') (Line: 138)
    Drupal\flexible_permissions\ChainPermissionCalculator->calculatePermissions(Object, 'individual') (Line: 41)
    Drupal\group\Access\GroupPermissionCalculator->calculateFullPermissions(Object) (Line: 40)
    Drupal\group\QueryAccess\GroupQueryAlter->doAlter('view') (Line: 150)
    Drupal\group\QueryAccess\QueryAlterBase->alter(Object, Object) (Line: 336)
    group_query_entity_query_alter(Object, NULL, NULL) (Line: 545)
    Drupal\Core\Extension\ModuleHandler->alter('query', Object) (Line: 495)
    Drupal\Core\Database\Query\Select->preExecute() (Line: 503)
    Drupal\Core\Database\Query\Select->preExecute() (Line: 520)
    Drupal\Core\Database\Query\Select->execute() (Line: 266)
    Drupal\Core\Entity\Query\Sql\Query->result() (Line: 84)
    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 316)
    Drupal\Core\Entity\Query\QueryBase->initializePager() (Line: 245)
    Drupal\Core\Entity\Query\Sql\Query->finish() (Line: 83)
    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 161)
    Drupal\group\Entity\Controller\GroupListBuilder->getEntityIds() (Line: 88)
    Drupal\Core\Entity\EntityListBuilder->load() (Line: 241)
    Drupal\Core\Entity\EntityListBuilder->render() (Line: 141)
    Drupal\group\Entity\Controller\GroupListBuilder->render() (Line: 23)
    Drupal\Core\Entity\Controller\EntityListController->listing('group')
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
    Drupal\tracer\StackMiddleware\TracesMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • πŸ‡§πŸ‡ͺBelgium Axael

    I had the same error as the OP on my acceptance environment. I applied patch #4 which fixed that specific error, but there's another one now showing in the watchdog and causing a WSOD:

    Error : Call to a member function getPluginId() on null dans Drupal\group\GroupMembership->__construct() (/var/www/projects/xxx/web/modules/contrib/group/src/GroupMembership.php ligne 37)

    This error doesn't show on my local dev environment. Once the website is migrated to the acceptance environment, the error seems to hit only admin-level users except user ID1. Could it be related to permissions?

  • First commit to issue fork.
  • πŸ‡¬πŸ‡·Greece vensires

    I have the same issue in non-local servers after uninstalling a previously installed group node plugin. After clearing the cache, the issue seems to be fixed but in acceptance we don't have this right and the pipeline keeps failing.

    I will try the patch and update the ticket if I have a success. Created a MR for easier changes in case I find a solution for #15 πŸ› Error: Call to a member function getPluginId() on null in modules/contrib/group/src/Entity/Storage/GroupRelationshipStorage.php on line 93 Active while fixing the summary's issue first.

  • Pipeline finished with Success
    2 months ago
    Total: 1382s
    #313935
  • πŸ‡¬πŸ‡·Greece vensires

    Updated MR with latest changes in order to apply to Group v3.3.x. Uploading patch too.

  • Pipeline finished with Success
    2 months ago
    Total: 1099s
    #314170
Production build 0.71.5 2024