The logic in MediaLibrary::updateFormElement() needs to be updated to handle all available return types from NestedArray.

Created on 15 May 2024, about 1 month ago

Problem/Motivation

An error occurs when NestedArray::getValue() method returns something other than an Array. The logic in MediaLibrary::updateFormElement() doesn’t sufficiently handle all available return types from NestedArray.

This is occurring for me with Drupal core 10.2.1 and media_library_form_element 2.0.6.

Steps to reproduce

Given I navigate to a Layout Builder page
And I am editing a custom block
When I try to upload a background media image
The image doesn't get uploaded and I get the following error in the console:

TypeError: Drupal\media_library_form_element\Element\MediaLibrary::updateFormElement(): Return value must be of type array, null returned in Drupal\media_library_form_element\Element\MediaLibrary::updateFormElement() (line 412 of media_library_form_element/src/Element/MediaLibrary.php)

Proposed resolution

Write a patch to gracefully handle NULL values.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇯🇴Jordan RaniaMashaqbeh

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

Comments & Activities

Production build 0.69.0 2024