Problem/Motivation

I'm getting the folowing error :

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in file /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php on line 1309

When i use media library or paragraphs widgets to add items.

I traced it down to this module definition of the validation callback in NodeMenusHooks::formNodeFormAlter :

$form['#validate'][] = [$this, 'validateNodeForm'];

which somehow causes the database service to be serialized.

Proposed resolution

Use static method as validation callback instead of "$this"

$form['#validate'][] = self::class . ':validateNodeForm';

This is very similar to https://www.drupal.org/project/webform/issues/3500726#comment-16295192

Issue fork node_menus-3624466

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

adel-by created an issue. See original summary.

adel-by’s picture

Assigned: adel-by » Unassigned
Status: Active » Needs review

  • adel-by committed d516a709 on 3.x
    fix: issue #3624466 prevent serialisation of services errors