While linking an entity (media/file) embed from a CK Editor we get the following exception if the autosave_form module is installed and enabled:

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() (line 1472 of /core/lib/Drupal/Core/Database/Connection.php).

Still looking into it further. Will post if I have a possible solution or workaround.

Comments

zainulhassan4 created an issue. See original summary.

zainulhassan4’s picture

Issue summary: View changes
hchonov’s picture

Could you please post the stack trace leading to serializing the DB connection?

zainulhassan4’s picture

StatusFileSize
new30.62 KB

Sorry about that. PFA the file. Would this suffice?

Thanks in advance.
Zain

hchonov’s picture

Unfortunately I cannot see as part of what is the connection being serialized. You'll have to continue looking into your setup. I have an installation where autosave_form is being used together with CKEdtior where media is being embedded and there are no problems.

zainulhassan4’s picture

hmm, its a wysiwyg in a paragraph.
If its working for you, then its a start at least.
I'll look into it further.

Thanks,

j3ll3nl’s picture

I got the same issue here on a wysiwyg field in a content type with entity_embed. When i insert the image it revalidates the form and the error hits.

web/modules/contrib/autosave_form/src/Form/AutosaveFormValidator.php:69

a.milkovsky’s picture

I am getting the same error. The error happens after entity_embed tries to rebuild the form. Looks like there is some data, which can not be serialized.

vermario’s picture

Same here: content type with paragraphs inside which we have ckeditor areas with entity_embed. Could it be the fact that we have paragraphs in the mix + translations that causes the issue?

Disabling the module "resolves" the issue, but it is not reallly an option in our situation. How can I help debugging this?

dgroene’s picture

Not sure if this is the best way to prevent serialization of the database connection, but is working for me.

  • hchonov committed cb140e1 on 8.x-1.x
    Issue #2980855 by dgroene, zainulhassan4, hchonov: Entity Embed breaks...
hchonov’s picture

Status: Active » Fixed

After debugging for a while I've found out that the problem is in core, because there is a bug regarding the "serialization" of decorated services. See #2896993: Decorated services crash on serialization. and #2531564: Fix leaky and brittle container serialization solution for more information. I've committed a workaround, which should solve the issue for everyone.

Status: Fixed » Closed (fixed)

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