Problem/Motivation

There is a nested function inside the buildForm() method in BlockSettingsForm class. As buildForm can get called more than once through an ajax request a fatal error is thrown:

Fatal error: Cannot redeclare Drupal\gutenberg\Form\array_flatten() (previously declared in /app/web/modules/contrib/gutenberg/src/Form/BlockSettingsForm.php:102) in /app/web/modules/contrib/gutenberg/src/Form/BlockSettingsForm.php on line 102"

Steps to reproduce

I've got a custom block which is using the media FAPI element added by media_library_form_element module. When the media library modal is triggered I think the form is rebuilt triggering this error.

Proposed resolution

Move array_flatten into it's own method in the class and call the method.

CommentFileSizeAuthor
#2 gutenberg-array_flatten-3281322-2.patch1.94 KBtanc

Comments

tanc created an issue. See original summary.

tanc’s picture

Status: Active » Needs review
StatusFileSize
new1.94 KB

Patch fixes the issue for me and allows the media library to display and no error in console.

marcofernandes’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.