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
This happens on both node save, and when adding a paragraph to a ERR field on a node.
When a user without the "bypass workbench access" permission attempts to save (I presume any) entity, with a section field that is empty a fatal error occurs:
TypeError: Argument 1 passed to Drupal\\workbench_access\\AccessControlHierarchyBase::checkEntityAccess() must implement interface Drupal\\Core\\Entity\\EntityInterface, null given, called in /data/app/modules/contrib/entity_hierarchy/modules/entity_hierarchy_workbench_access/src/Plugin/Validation/Constraint/ValidEntityHierarchySection.php on line 62
This is due to $parent = $items->entity;
assuming that a value is returned.
This also seems to occur when adding a new paragraph to an entity reference revisions field.
Proposed resolution
Add the violation if the field is empty and the "Deny access to unassigned content" flag is checked.
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff-4-9.txt | 1.08 KB | acbramley |
#9 | 2938432-9.patch | 2.73 KB | acbramley |
Comments
Comment #2
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedTaking a stab at this now.
Comment #3
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedHere's a test which surfaces the error.
EDIT: Missed the title on the node, will fix in follow up with actual fix.
Comment #4
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedComment #5
larowlanCan we return here (in both cases) and avoid the
elseif
(I like to avoid using else, but I really really like to avoid using elseif)Thanks
Comment #7
larowlanComment #8
larowlanJust need to address the maintainer's personal penchant for avoiding elseif ;)
Comment #9
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedHaha sure, I actually had it like this originally but thought elseif looked cleaner.
Comment #11
larowlanFixed, rolling a new alpha