Fix the logic in MediaLibrary::updateFormElement() needs to be updated to handle all available return types from Nested Array

Created on 15 May 2024, 6 months ago
Updated 4 August 2024, 4 months 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

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡ฏ๐Ÿ‡ดJordan RaniaMashaqbeh

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024