Problem/Motivation
Warning: Undefined array key "delete" in Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormComplex::submitConfirmRemove() (line 1013)
Steps to reproduce
Remove any IEF. (ief_remove_confirm)
Proposed resolution
Check if delete exists in array.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork inline_entity_form-3416328
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
saidatomComment #4
dimilias commentedFor reference, this is reproducible only if the user does not have the access to delete the entity removed. In
web/modules/contrib/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php:914there is a check alreadyand the
deletecheckbox is not added if the user does not have 'delete' access. This, checking either for the access or if the array key exists is a valid case.I don't know if tests are needed as this is a warning and a simple missing check that does not affect the end result. The user does not have access, the entity is also not marked for deletion.
Comment #5
geek-merlinThx a lot, this makes a lot of sense.
But code is overly complex. Please use the more idiomatic
!empty($form_values['delete'])Comment #7
bharath-kondeti commentedComment #8
arthur.baghdasar commentedComment #10
anybody@geek-merlin I simplified the code as suggested in #5. So I guess this can be merged.
Comment #12
bluegeek9 commentedI added a variable for the if() statement to make it clearer what the intent is. I also added a kernel test.
Comment #13
anybodyThank you, LGTM!
Comment #15
dwwComment #18
dwwThanks for working on this! Especially thanks @bluegeek9 for the Kernel test. I confirmed locally it fails without the fix applied. Can also see it at https://git.drupalcode.org/project/inline_entity_form/-/jobs/10122967 in the last pipeline.
I pushed a commit to try to improve the readability of the
ifstatement. I ran the full pipeline on all versions of core, and everything is green: https://git.drupalcode.org/project/inline_entity_form/-/pipelines/837497Merged to 3.x.
Thanks again!
-Derek
Comment #20
anybodyThank YOU very much @dww for merging all these changes now! Very important, thanks!