Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#15 | 2866323-15.patch | 7.35 KB | Suresh Prabhu Parkala |
#10 | 2866323-10.patch | 7.35 KB | Suresh Prabhu Parkala |
#10 | interdiff_8-10.txt | 744 bytes | Suresh Prabhu Parkala |
#8 | 2866323-8.patch | 7.34 KB | Suresh Prabhu Parkala |
#2 | 2866323-fix_entity_relationship_with_no_value.patch | 6.64 KB | andrewbelcher |
Comments
Comment #2
andrewbelcher CreditAttribution: andrewbelcher at FreelyGive commentedHere is a fix for the issue, including a test demonstrating the problem/it's fix.
Comment #3
andrewbelcher CreditAttribution: andrewbelcher at FreelyGive commentedComment #5
joachim CreditAttribution: joachim at Torchbox commented+1 from me, and critical I'd say, as without this patch just a call to get plugins crashes:
Comment #6
joelpittetThe patch in #3007028: Having Commerce installed makes TypedDataRelationshipDeriver throw a fatal error looks much simpler solution. Not sure which direction is correct off hand.
Comment #7
mlncn CreditAttribution: mlncn at Agaric for Drutopia, Cambridge, Massachusetts Family Policy Council, Find It Cambridge commentedThis needs a re-roll (or possibly a decision, per #6)
Comment #8
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedRe-rolled patch Please review!
Comment #10
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedUpdated patch.
Comment #11
KapilV CreditAttribution: KapilV as a volunteer and at OpenSense Labs commentedComment #12
mlncn CreditAttribution: mlncn at Agaric for Drutopia, Cambridge, Massachusetts Family Policy Council, Find It Cambridge commentedThis is working.
Comment #13
Chris Matthews CreditAttribution: Chris Matthews as a volunteer and at City of Oaks Design commentedComment #14
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedComment #15
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedRe-rolled patch please review.
Comment #16
Chris Matthews CreditAttribution: Chris Matthews as a volunteer and at City of Oaks Design commentedComment #18
japerry