Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Adding conditions to an element throws "LogicException: The database connection is not serializable. "
Steps to reproduce...
Goto /admin/structure/webform/manage/contact/element/email/edit
Add multiple conditions to 'Conditional Logic'
Proposed resolution
TDB
Notes
Webform entity is being serialized and throwing the error.
Fixed when not passing the Webform entity to the form and access check.
Comment | File | Size | Author |
---|---|---|---|
#5 | logicexception_the-2901697-4.patch | 9.97 KB | jrockowitz |
| |||
#3 | logicexception_the-2901697-3.patch | 5.88 KB | jrockowitz |
#2 | logicexception_the-2901697-2.patch | 2.85 KB | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz commentedAttached patch is a half baked workaround where the webform id is passed to the access check and form.
Comment #3
jrockowitz CreditAttribution: jrockowitz commentedThe issue is that the WebformHandlers were serializing
$container->get('logger.factory')->get('webform')
. WebformHandlers are initialized with the Webform entity.Notes
Error not occurring when Webform has not handlers.
Solution
Don't store the webform logger, instead store the logger factory.
Comment #5
jrockowitz CreditAttribution: jrockowitz commentedComment #7
jrockowitz CreditAttribution: jrockowitz commentedComment #10
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commentedThe patch from #4 when applied to 5.0-beta16 doesn't work.
Comment #11
jrockowitz CreditAttribution: jrockowitz commentedThere have been some major improvements since beta16, you might need to manually reroll the patch or update to the latest dev release.
Comment #12
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commentedThanks, will try tomorrow.
The patch appeared to apply cleanly though.
Comment #13
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commented@jrockowitz do you know a method to quickly see where the database connection is coming from. I know it's somewhere in the render array but it's impossible the see where it is coming from.
Comment #14
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commented@jrockowitz I just updated to 5.x-dev and this error is still happening.
It only happens on webforms with multiple pages though.
Comment #15
jeroen.b CreditAttribution: jeroen.b at .VDMi/ commentedI managed to fix it!
I have a custom element and did:
Now changed it to:
And made the validate function static.
No idea why it worked before. My element just extends the Radios element so it should manage the serialization just fine.
I used the following code snipped in PhpSerialize:
I breakpointed the
if ($e) {
, so I would have the exact path that causes the error.I added the following function to the
encode($data)
function in PhpSerialize before the actual serialize: