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
- Install `paragraphs_ee` on Drupal 11.
- Edit any paragraph type (`admin/structure/paragraphs_type/{type}`).
- 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).
Issue fork paragraphs_ee-3594435
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 #3
peri22 commentedComment #4
peri22 commentedOpened MR with the fix.
Comment #6
frouco commentedThe patch worked correctly for us.
Comment #7
stborchert