Problem/Motivation
After changes in #3444471: Put procedural code into OOP code, when using a media library widget in Layout Builder, when clicking the "add media" button there is a fatal error:
The website encountered an unexpected error. Try again later.Exception: Serialization of 'Closure' is not allowed in serialize() (line 15 of core/lib/Drupal/Component/Serialization/PhpSerialize.php). Drupal\Component\Serialization\PhpSerialize::encode(Array) (Line: 112)
This is due to;
\array_unshift($form['#submit'], [$this, 'submitForm']);
in app/modules/contrib/ui_styles/modules/ui_styles_layout_builder/src/HookHandler/FormLayoutBuilderBlockAlter.php, using $this makes the form cache system try to serialize the hook handler and there is a service in it.
Proposed resolution
Either change the code like:
\array_unshift($form['#submit'], ['::submitForm']);
Or try using DependencySerializationTrait
Issue fork ui_styles-3447102
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
grimreaper