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

Command icon 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

Grimreaper created an issue. See original summary.

  • Grimreaper committed 81d3edb2 on 8.x-1.x
    Issue #3447102 by Grimreaper: Serialization of Closure is not allowed in...
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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