Closed (duplicate)
Project:
Drupal core
Version:
8.5.x-dev
Component:
dblog.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Dec 2012 at 15:34 UTC
Updated:
25 Mar 2018 at 15:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerAs errors could put any kind of value into the message it seems to be required to check and filter
out the variables by serializable content. http://stackoverflow.com/questions/5775094/test-if-a-variable-is-seriali... lists some ways to do it, though all feels kind of ugly.
Comment #2
das-peter commentedJust struggled over this while working on #1818556: Convert nodes to the new Entity Field API.
One of the errors is buried in
LegacyControllerSubscriber::onKernelControllerLegacy():This leads to following trace in the case of an error:

I'm not sure how to proceed, if we've a chance to catch all closures it would be nice to give serializable closures a try.
But it's likely we need a defensive serializing function to deal with all possible cases, even if we build serialzable closures, in sensitive locations. Maybe something like this:
Comment #3
das-peter commentedRelated #1934738: Exception: Serialization of 'Closure' is not allowed in serialize() (line 154 of dblog.module)
Comment #4
das-peter commentedHere's a first patch.
Comment #6
das-peter commentedOh, that assertion had a Windows specific file path in it. Now it's generic.
Comment #7
Crell commentedCan someone perhaps explain to me WHY we need to serialize a closure? What exactly is the use case? The legacy url matcher's closure is not a use case, since I cannot imagine why anyone would be serializing that. It's also intended to be removed once everything is ported to the new routing system.
Comment #8
dawehnerWell it's not that we need to support it, though when you throw an exception/error and somewhere in the stack is a db connection,
you can't log the error at the moment. This hasn't been a problem in D7, because you never actually stored the db connection somewhere.
Comment #9
Crell commentedStoring the DB connection? Wha? Now I'm even more confused.
Comment #10
dawehnerWith "storing" i wanted to express: Something which has the db connection injected.
Comment #11
das-peter commentedThe reason for me to create this was that the "Node creation" test has a test case in which an exception is thrown. The test checks then if the watchdog contains the expected exception.
Unfortunately (on Windows / or even just within my installation) there's a closure in the backtrace of the exception. And this closure kills the whole exception handling because the backtrace can't be serialized.
Now instead to fix "just" the backtrace handling I decided to go for a more "general" solution.
Comment #12
Crell commentedpeter: Try looking at Symfony's FlattenException class. It's a bit odd, but I think it's also addressing a similar issue in a less language-hostile way. :-)
Or, really, why are we serializing an entire backtrace...?
There's so much here that doesn't make sense to me.
Comment #13
berdirThe real problem here is #1158322: Add backtrace to all errors IMHO, that's the reason this happens in the first place.
While it makes sense to prevent it for other cases, fixing the other issue is IMHO more important so that we never try to serialize a whole backtrace in the first place.
Comment #14
jibran#6: core-serializable-closure-1872690-6.patch queued for re-testing.
Comment #21
dagmarDuplicate of #2481349: Prevent the use of placeholders that cannot be converted into strings when creating logs