Problem/Motivation

Drupal\paragraphs_ee\Hook\FormHooks::paragraphsTypeFormAlter() appends [$this, paragraphsTypeFormBuilder] to $form[#entity_builders].

FormHooks injects EntityTypeManagerInterface, but does not use DependencySerializationTrait. When the paragraph type form is cached for an AJAX rebuild — for example, when uploading an icon via the core icon_file
managed_file element — Drupal serializes the form array, including $this, which holds an indirect reference to the database connection.

Steps to reproduce

  1. Install `paragraphs_ee` on Drupal 11.
  2. Edit any paragraph type (`admin/structure/paragraphs_type/{type}`).
  3. Upload an image in the Paragraph icon field (this triggers the `managed_file` AJAX callback).

Result: 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 Drupal\Core\Database\Connection->__sleep()

Proposed resolution

Add DependencySerializationTrait to FormHooks so injected services are replaced by their service IDs on serialization (the trait the exception message itself recommends).

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

peri22 created an issue. See original summary.

peri22’s picture

Status: Active » Needs review
peri22’s picture

Opened MR with the fix.

  • peri22 committed 76d059bd on 10.1.x
    Issue #3594435: Add DependencySerializationTrait to FormHooks to fix...
frouco’s picture

The patch worked correctly for us.

stborchert’s picture

Version: 10.1.0 » 10.1.x-dev
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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