Problem/Motivation

\Drupal\ctools\Plugin\Relationship\TypedDataEntityRelationship::getRelationship causes a fatal error if the entity reference field is empty. This is because it assumes there is a value to order to retrieve the entity type.

Proposed resolution

Find a different way to build the definition. I'm assuming returning NULL would be bad here, so I'm thinking retrieving the entity type via the field definition would be the best approach, possibly even as part of the deriver so it gets cached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewbelcher created an issue. See original summary.

andrewbelcher’s picture

Here is a fix for the issue, including a test demonstrating the problem/it's fix.

andrewbelcher’s picture

Status: Active » Needs review

The last submitted patch, 2: 2866323-fix_entity_relationship_with_no_value-test_only.patch, failed testing.

joachim’s picture

Priority: Major » Critical

+1 from me, and critical I'd say, as without this patch just a call to get plugins crashes:

  $pm = \Drupal::service('plugin.manager.ctools.relationship');
  $pm->getDefinitions();
joelpittet’s picture

The patch in #3007028: Having Commerce installed makes TypedDataRelationshipDeriver throw a fatal error looks much simpler solution. Not sure which direction is correct off hand.

mlncn’s picture

Status: Needs review » Needs work

This needs a re-roll (or possibly a decision, per #6)

Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
FileSize
7.34 KB

Re-rolled patch Please review!

Status: Needs review » Needs work

The last submitted patch, 8: 2866323-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
FileSize
744 bytes
7.35 KB

Updated patch.

KapilV’s picture

Issue tags: +fatal error
mlncn’s picture

Status: Needs review » Reviewed & tested by the community

This is working.

Chris Matthews’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -fatal error +Needs reroll
Suresh Prabhu Parkala’s picture

Assigned: Unassigned » Suresh Prabhu Parkala
Suresh Prabhu Parkala’s picture

Assigned: Suresh Prabhu Parkala » Unassigned
Status: Needs work » Needs review
FileSize
7.35 KB

Re-rolled patch please review.

Chris Matthews’s picture

Issue tags: -Needs reroll

  • japerry committed e5249b5 on 8.x-3.x authored by andrewbelcher
    Issue #2866323 by andrewbelcher: Fatal error on empty entity reference...
japerry’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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