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.
Scenario:
- A paragraph bundle contains an entity reference field (node).
- A paragraphs field using the bundle is configured to use the "preview " edit mode.
- A referenced node has been deleted without first removing the reference.
- Trying to edit or remove the pargraphs item that contains the missing reference causes a fatal error.
Background on the error:
- InlineParagraphsWidget::elementValidate() calls $display->validateFormValues().
- A ValidReferenceConstraint violation is detected.
- Ultimately WidgetBase::flagErrors() is called which attempts to retrieve the widget state.
- $field_state is null, and thus null gets passed as second argument to NestedArray::getValue() which causes:
Recoverable fatal error: Argument 2 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given
Comment | File | Size | Author |
---|---|---|---|
#17 | edit_modes_closed_and-2708033-16-test-only.patch | 4.62 KB | johnchque |
#16 | interdiff-2708033-9-16.txt | 5.1 KB | johnchque |
#16 | edit_modes_closed_and-2708033-16.patch | 6.03 KB | johnchque |
#13 | edit_modes_closed_and-2708033-13.patch | 4.44 KB | chr.fritsch |
#9 | edit_modes_closed_and-2708033-9.patch | 3.75 KB | johnchque |
Comments
Comment #2
ciss CreditAttribution: ciss as a volunteer commentedI just did another check with the "closed" edit mode, achieving the same result. Only the "open" edit mode allows the item to be edited or removed.
Comment #3
ciss CreditAttribution: ciss as a volunteer commentedUpdating issue title.
Comment #4
johnchqueWhat field type where you using to make the reference to the node? in:
Comment #5
ciss CreditAttribution: ciss as a volunteer commentedThe field type is a Drupal 8.0.6 core entity reference field. The field config can be found here: https://goo.gl/80IuXY
Comment #6
johnchqueThis should fix the problem but not sure if this is the correct aproach.
Comment #7
miro_dietikerIf remove and removed was excluded, what ist the item state then of the item that accidentally triggers validation?
Comment #8
miro_dietikerAh i see... And since editing can only happen in edit state, your approach makes sense.
Test coverage? ;-)
Comment #9
johnchqueTests added. :D
Comment #13
chr.fritschIf we modify the patch like this we, can fix this issue #2722097: IEF Simple Widget not working in paragraphs with preview mode too.
Comment #14
johnchque@chr.fritsch I think would be better to have a separated issue to fix the problem you refer. Also if would be much better to have test coverage for what you describe and provide a test-only patch that should fail.
Comment #15
johnchqueTested a bit more, we need extra tests.
Comment #16
johnchqueWe definitely need to refactor tests after release. Added tests, Discussed with @Berdir we shouldn't be able to collapse with an invalid reference.
Comment #17
johnchqueSorry, forgot the test-only patch. :)
Comment #21
johnchqueGlad to know test only patch failed. :)
Comment #22
BerdirNice, looks good to me.
As a follow-up, Miro and I discussed that we could do the following:
For closed paragraphs, directly validate them with $entity->validate(). If there are validation errors, just list them within the closed paragraph as error messages. On submit, fail validation on them, just add the messages on the current form element.
Can you create that?
Comment #23
miro_dietikerCommitted.
Back to needs work to create the followups. Please close when created and referenced.
Comment #25
johnchqueIssue created.