Undefined array key on file remove

Created on 14 February 2023, almost 2 years ago
Updated 10 August 2024, 4 months ago

Problem/Motivation

I have a File-field that uses the default File-field widget. I am able to add a new file to the field correctly, but when I try to remove it on the node edit page, I receive the following error:

Warning: Undefined array key -2 in entity_browser/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php on line 817

Proposed resolution

Add check that the array key exists.

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component

Field widget

Created by

🇫🇮Finland thatguy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @thatguy
  • 🇫🇮Finland thatguy

    Added check for the array key. Fixed issue for me so now I'm able to remove the file in node edit form.

  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇨🇭Switzerland idflood

    I confirm the patch in #2 fixed the same issue as described in op. Thanks @thatguy !

  • Status changed to RTBC 8 months ago
  • 🇨🇦Canada maursilveira Windsor, ON

    I tested the patch #2 against the version 2.10.0 of the module, and it does fix the issue.

    Thank you @thatguy!

  • 🇺🇸United States cbfannin

    I did a clean install on simplytest.me with 8.x-2.10 and not seeing this issue.

    My test steps were:
    - Installed 8.x-2.10 (unpatched).
    - Created a new Entity Browser adding the upload widget.
    - Added an entity reference field to the page node type.
    - Set the entity reference field's form display to Entity Browser.
    - Created a new node.
    - Selected an image with the new field.
    - Saved the node.
    - Edited the node.
    - Clicked the "Removed" button.
    Result: The image was removed with no reported errors.

    Again this was a clean install with no patches.
    If anyone wants to provide their test steps, I am more than happy to test again.

  • Status changed to Closed: duplicate 4 months ago
Production build 0.71.5 2024