Problem/Motivation

My test cleanup script stumbled on this. An exception is thrown when a membership is deleted after its user.

Steps to reproduce

- Delete a membership after its user.

Exception in Drupal\Tests\c4c\ExistingSite\DGOContractTest::tearDownAfterClass
Call to a member function id() on null

web/modules/contrib/ginvite/ginvite.module:209
web/modules/contrib/hux/src/HuxModuleHandler.php:114
web/modules/contrib/hux/src/HuxModuleHandler.php:100
web/core/lib/Drupal/Core/Extension/ModuleHandler.php:395
web/modules/contrib/hux/src/HuxModuleHandler.php:103
web/modules/contrib/hux/src/HuxModuleHandler.php:121
web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:215
web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:900
web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:462
web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:753
web/modules/contrib/group/group.module:465
web/modules/contrib/hux/src/HuxModuleHandler.php:114
web/modules/contrib/hux/src/HuxModuleHandler.php:100
web/core/lib/Drupal/Core/Extension/ModuleHandler.php:395
web/modules/contrib/hux/src/HuxModuleHandler.php:103
web/modules/contrib/hux/src/HuxModuleHandler.php:121
web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:217
web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:900
web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:462
web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:753
web/core/lib/Drupal/Core/Entity/EntityBase.php:362
web/modules/custom/c4c/tests/src/ExistingSite/ContentCleanup/EntityWatcher/EntityWatcher.php:48
web/modules/custom/c4c/tests/src/ExistingSite/BaseClass/C4cExistingSiteBase.php:56
vendor/bin/phpunit:122


Proposed resolution

s/$group_relationship->getEntity()->id()/$group_relationship->getEntityId()/
and avaid the anyway not necessary entity load.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork ginvite-3480202

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

Status: Active » Needs review

ME applies cleanly on my site and fixes the issue for me.

lobsterr made their first commit to this issue’s fork.

  • geek-merlin committed 54c0ed12 on 4.0.x
    Issue #3480202: Exception when membership is deleted after user
    

  • lobsterr committed 6e2cba90 on 3.0.x
    Issue #3480202 by geek-merlin, lobsterr: Exception when membership is...

  • lobsterr committed 82a7eb53 on 2.x
    Issue #3480202 by geek-merlin, lobsterr: Exception when membership is...
lobsterr’s picture

Status: Needs review » Fixed

Thank you for your contribution. I will tag a new release

geek-merlin’s picture

Thanks for the quick commit!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

brooke_heaton’s picture

This is also happening on 3.0.0-rc3.

Call to a member function id() on null in ginvite_group_content_delete() (line 209 of modules/contrib/ginvite/ginvite.module). call_user_func_array(Object, Array) (Line: 416)

Happy to open a new ticket if needed.

lobsterr’s picture

No, no need to open, I will check

lobsterr’s picture

@brooke_heaton, it looks like you are using not 3.0.0-rc3,

As you can see here in this ticket I fixed the issue: fix

And the right code is there, in your error you have a call of id(), but it was removed : https://git.drupalcode.org/project/ginvite/-/blob/3.0.x/ginvite.module?ref_type=heads#L209

I believe you are still on rc2. Could you checked it