Undefined array key "weight" when adding multiple media

Created on 6 April 2022, over 2 years ago
Updated 26 January 2024, 10 months ago

Problem/Motivation

Can't attach more than 1 media library item

Steps to reproduce

  • Add multi-value media item (pdf file in my case). This field is set to be Unlimited
  • Save node
  • Edit node and try to add another media item.
  • Second media item not added.
  • Error when inspecting the page: Undefined array key \"weight\" in /app/web/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php on line 856

Proposed resolution

add validation if key weight is set

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

9.5

Component
MediaΒ  β†’

Last updated about 6 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States vlyalko

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡΅πŸ‡ΉPortugal joum Porto

    Can confirm this still applies cleanly on Drupal 10.1.6.

    Does it only require automated tests to move forward to RTBC?

Production build 0.71.5 2024