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

Command icon 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

saidatom created an issue. See original summary.

saidatom’s picture

Status: Active » Needs review
dimilias’s picture

Status: Needs review » Reviewed & tested by the community

For 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:914 there is a check already

    if (!empty($entity_id) && $this->getSetting('removed_reference') === self::REMOVED_OPTIONAL && $entity->access('delete')) {

and the delete checkbox 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.

geek-merlin’s picture

Status: Reviewed & tested by the community » Needs work

Thx a lot, this makes a lot of sense.

But code is overly complex. Please use the more idiomatic !empty($form_values['delete'])

bharath-kondeti made their first commit to this issue’s fork.

bharath-kondeti’s picture

Status: Needs work » Needs review
arthur.baghdasar’s picture

Status: Needs review » Reviewed & tested by the community

anybody made their first commit to this issue’s fork.

anybody’s picture

@geek-merlin I simplified the code as suggested in #5. So I guess this can be merged.

bluegeek9 changed the visibility of the branch 3.x to hidden.

bluegeek9’s picture

I added a variable for the if() statement to make it clearer what the intent is. I also added a kernel test.

anybody’s picture

Thank you, LGTM!

dww made their first commit to this issue’s fork.

dww’s picture

Title: Undefined array key "delete" » Undefined array key 'delete' if user does not have permission to delete the entity

  • dww committed 7267e835 on 3.x
    fix: #3416328 Undefined array key 'delete' if user does not have...

dww’s picture

Status: Reviewed & tested by the community » Fixed

Thanks 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 if statement. I ran the full pipeline on all versions of core, and everything is green: https://git.drupalcode.org/project/inline_entity_form/-/pipelines/837497

Merged to 3.x.

Thanks again!
-Derek

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

anybody’s picture

Thank YOU very much @dww for merging all these changes now! Very important, thanks!