LogicException: The database connection is not serializable.
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3352641. -->
Reported by: [jeremy.zimmermann](https://www.drupal.org/user/283199)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Error when saving subscriptions on user profile page: </p>
<pre>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 1687 of /home2/atwh9578/***/core/lib/Drupal/Core/Database/Connection.php). {"severity_level":3,"@backtrace_string":"#0 [internal function]: Drupal\\Core\\Database\\Connection->__sleep()<br>#1 /home2/atwh9578/***/modules/contrib/danse/modules/form/src/Payload.php(74): serialize()<br>#2 /home2/atwh9578/***/modules/contrib/danse/src/PayloadBase.php(35): Drupal\\danse_form\\Payload->prepareArray()<br>#3 /home2/atwh9578/***/modules/contrib/danse/src/Entity/Event.php(55): Drupal\\danse\\PayloadBase->toArray()<br>#4 /home2/atwh9578/***/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(87): Drupal\\danse\\Entity\\Event::preCreate()<br>#5 /home2/atwh9578/***/core/lib/Drupal/Core/Entity/ContentEntityBase.php(1143): Drupal\\Core\\Entity\\ContentEntityStorageBase->create()<br>#6 /home2/atwh9578/***/modules/contrib/danse/src/PluginBase.php(365): Drupal\\Core\\Entity\\ContentEntityBase::create()<br>#7 /home2/atwh9578/***/modules/contrib/danse/modules/form/src/Plugin/Danse/Form.php(47): Drupal\\danse\\PluginBase->createEvent()<br>#8 /home2/atwh9578/***/modules/contrib/danse/modules/form/danse_form.module(45): Drupal\\danse_form\\Plugin\\Danse\\Form->createFormEvent()<br>#9 [internal function]: danse_form_submit_event()<br>#10 /home2/atwh9578/***/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array()<br>#11 /home2/atwh9578/***/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\\Core\\Form\\FormSubmitter->executeSubmitHandlers()<br>#12 /home2/atwh9578/***/core/lib/Drupal/Core/Form/FormBuilder.php(595): Drupal\\Core\\Form\\FormSubmitter->doSubmitForm()<br>#13 /home2/atwh9578/***/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\\Core\\Form\\FormBuilder->processForm()<br>#14 /home2/atwh9578/***/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\\Core\\Form\\FormBuilder->buildForm()<br>#15 [internal function]: Drupal\\Core\\Controller\\FormController->getContentResult()<br>#16 /home2/atwh9578/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()<br>#17 /home2/atwh9578/***/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()<br>#18 /home2/atwh9578/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext()<br>#19 /home2/atwh9578/***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()<br>#20 /home2/atwh9578/***/vendor/symfony/http-kernel/HttpKernel.php(163): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()<br>#21 /home2/atwh9578/***/vendor/symfony/http-kernel/HttpKernel.php(74): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()<br>#22 /home2/atwh9578/***/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel->handle()<br>#23 /home2/atwh9578/***/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()<br>#24 /home2/atwh9578/***/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()<br>#25 /home2/atwh9578/***/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass()<br>#26 /home2/atwh9578/***/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\\page_cache\\StackMiddleware\\PageCache->handle()<br>#27 /home2/atwh9578/***/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()<br>#28 /home2/atwh9578/***/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\<br>egotiationMiddleware->handle()<br>#29 /home2/atwh9578/***/core/lib/Drupal/Core/DrupalKernel.php(686): Drupal\\Core\\StackMiddleware\\StackedHttpKernel->handle()<br>#30 /home2/atwh9578/***/index.php(19): Drupal\\Core\\DrupalKernel->handle()<br>#31 {main}","exception":[],"channel":"php","link":"","uid":"1","request_uri":"https://***/fr/user/1/subscriptions","referer":"https://***/fr/user/1/subscriptions","ip":"**.**.**.**","timestamp":1680773426}</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p> - Create a subscription on a content type<br>
- Subscribe to this event on a user profile subscription page</p>
<h4 id="summary-steps-reproduce">Workarround</h4>
<p>You can disable danse_form submodule to avoid this error.</p>
<h4 id="summary-data-model-changes">Version</h4>
<p>D10.0.7<br>
PHP 8.1.17<br>
DANSE 2.2.15, also tested with 2.2.x-dev</p>
> Related issue: [Issue #3351589](https://www.drupal.org/node/3351589)
issue