When I create a new meta entity type, and I then try to create one of the meta entities through the UI using the default settings, I am getting the following error:

Error: Call to a member function getEntityTypeId() on null
/home/pieter/v/joinup-dev/web/modules/contrib/meta_entity/src/Plugin/Validation/Constraint/MappedTargetEntityValidator.php:45

This is because in the default configuration the entity reference to the target entity is hidden from the form display, and the entity is saved without referencing the target entity. The code does not account for the fact that the reference might be empty.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Status: Active » Needs review
FileSize
2.13 KB
1.24 KB

Here's a patch and a test.

Status: Needs review » Needs work

The last submitted patch, 2: 3080887-2-test-only.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community

Thanks!

pfrenssen’s picture

Status: Reviewed & tested by the community » Needs review

Thanks for quick review!

The test result shows the error I was encountering:

1) Drupal\Tests\meta_entity\Kernel\MappedTargetEntityConstraintTest::testConstraint
Error: Call to a member function getEntityTypeId() on null
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

  • pfrenssen committed 484ccae on 8.x-1.x
    Issue #3080887 by pfrenssen: Fatal error when creating meta entity...
pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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