Creating a GroupRelationship with invalid type (eg not yet installed) throws confusing exception

Created on 14 January 2024, over 1 year ago

Problem/Motivation

Creating a groupRelationship with non-existeint (e.g. not yet insallled) type throws a confusing exception:

Error: Call to a member function getPluginId() on null in Drupal\group\Entity\Storage\GroupRelationshipStorage->getEntityClass() (line 93 of /home/merlin/Code-Incubator/site-c4c-dev/web/modules/contrib/group/src/Entity/Storage/GroupRelationshipStorage.php).
#0 web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(84): Drupal\group\Entity\Storage\GroupRelationshipStorage->getEntityClass()
#1 web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(1172): Drupal\Core\Entity\ContentEntityStorageBase->create()
#2 web/modules/custom/c4c/src/Workflow/Subscriber/C4cOrderWorkflowSubscriber.php(171): Drupal\Core\Entity\ContentEntityBase::create()
#3 web/modules/custom/c4c/src/Workflow/Subscriber/C4cOrderWorkflowSubscriber.php(127): Drupal\c4c\Workflow\Subscriber\C4cOrderWorkflowSubscriber->creatGroupInvitation()

Steps to reproduce

In my case, programatically try to create a GInvite before installing the plugin. But any plugin will do.

    $invitation = GroupRelationship::create([
      'type' => $relationTypeId,
      'gid' => $group->id(),
      'invitee_mail' => $email,
      'entity_id' => 0,
    ]);

Proposed resolution

Check GroupRelationshipType and throw sth meaningful.

๐Ÿ› Bug report
Status

Active

Version

3.3

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024