-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading from 2.16.3 to 2.17.0 breaks serialization when using symfony/var-exporter #11063
Comments
2a9390d seems to be causing this |
Hi. I have the same error. Reverting to 2.16.3 solves the problem. |
For me it was resolved by purging our cache more explicitly. |
I can fix the issue by replacing the code that returns the properties to be serialized. In return array_values(array_diff(array_keys(get_object_vars($this)), ["_sqlStatements"])); |
@alcohol Which version do you finally have? |
I take it back, development release works (but runs in development mode). Production broken again. Manually purging caches did not resolve it there. Diving back into what the cause is. |
Weird, locally and on development we use
On production we use
Switching to Update Still broken on production. Working fine locally and on development. Investigating further.. |
Upgrade to 2.17.0 also broke our code, downgrading to 2.16.3 now. |
Same here in prod : purging the cache offers me a few request working, then same error. Investigating too. |
This is what initially fixed it for me when I mentioned it here #11027 (comment) 2 weeks ago. By "more explicitly", I mean I had to physically flush the Redis cache manually by flushing the whole redis db - for some reason the cli commands just did not clear the cache "enough". Ive been running the new code in production for 2 weeks now with no issues since that day 2 weeks ago #11048 Is Redis the clue here? 🤷♂️ |
I would prefer not to clear our entire Redis cache.. but it is worth investigating perhaps. |
Clear the query cache (not the result cache, just the query cache) should be sufficient. What happened is I made the serialization format compatible with 3.0.x, so now all mentions of orm/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php Lines 92 to 94 in e8afa9f
My assumption when writing this piece of code is that you cannot have both properties null at the same time after deserialization. |
That is a part of our release workflow though; so that is not sufficient unfortunately 😞 |
@PhilETaylor probably yes. We also use redis and cannot do flush it in the prod environment. This is why we have reverted to 2.16.3. |
Is |
If anyone can reproduce this with a test, it would help a lot. The test could be contributed here: https://github.com/doctrine/orm/blob/2.17.x/tests/Doctrine/Tests/ORM/Functional/ParserResultSerializationTest.php |
I'm at a loss then kind of. Our own code where the issue starts is:
This is a custom repository class that extends The entity it manages implements From there on onwards though it is all Doctrine vendor code. It even explicitly calls |
I would be very surprised if this is unrelated to my change wrt the query cache. Here is what a cache entry should look like:
Can somebody produce a cache entry that produces a broken |
It seems like the return array_values(array_diff(array_keys(get_object_vars($this)), ["_sqlStatements"])); |
With the code above: ➜ system git:(master) grep -ir "SqlStatemen" *
6R70MIgpdM/Z/P/18gNFO5JUiaR9dDGtcRg: 'sqlStatements' => [ The faulty code does not return anything, meaning the sqlStatements key is not being filled at all. |
@kerbert101 what's weird is that the piece of code you're modifying is the one that governs serialization. Its goal is to ensure |
@greg0ire Yes, I'm aware of the fact that it governs what to serialize. I'm switching to As you can see in the grep result, my modification will still ensure sqlStatements is serialized, not _sqlStatements. Anyways, i'm not saying this is the fix, but this is what I see |
Ok… I'm trying to simplify, but both seem to work the same: So why did I use |
But do we have parent classes here? The properties are protected, not private, and they are implemented by children of the abstract class. |
It's triggered by the exporter using |
Let me be more explicit: |
OK. So this is a Symfony bug, right? |
Nope, it's a Doctrine bug, |
@nicolas-grekas I do think you are correct in that |
How is it a Doctrine bug if everything works (there is not even a notice if I understood correctly) when using |
It works because it's broken : __sleep fails and then php likely falls back to standard behavior, ignoring __sleep, thus generating a serialized payload that works, but doesn't achieve the wanted compatibility I'd say. It's my guess at least :) |
And the difference of behavior might be related to VarExporter not falling back to the exact same behavior when __sleep returns a broken payload. That'd explain everything. But the root issue is in Doctrine. |
@nicolas-grekas I think it works just fine: https://3v4l.org/3ckU7 If PHP was falling back to standard behavior then we would see 2 properties, and here there is just |
Oh, OK! Then you're relying on undocumented behavior of __sleep! (and unimplemented in VarExporter) |
Yeah that sounds more plausible 😅 It's not part of the official docs, but I thought it would be good enough. The other occurrences, for reference: orm/lib/Doctrine/ORM/Query/ParserResult.php Lines 143 to 144 in e8afa9f
I think to address this, a possibility might be to iterate of the result of |
|
I think it would work just fine, unless somebody external to Doctrine have their own extending class, with their own |
@kerbert101 thanks for working on this! |
Fix for Symfony: symfony/symfony#52618 Thank you all for the help on this one! |
Upgrading from
which means |
Thanks, but we have 2 fixes on the way already, and pinpointed the issue a few messages ago. You just need to wait for either a new version of |
Hi, I've got the same issue after upgrade to
Stacktrace:
|
@szczyglis-dev I said: YOU JUST NEED TO WAIT So just wait. No need for more reports. |
Awesome, many thanks to everyone who got involved so quickly to resolve this 🥳 ! |
… by __sleep() (nicolas-grekas) This PR was merged into the 5.4 branch. Discussion ---------- [VarExporter] Fix handling mangled property names returned by __sleep() | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52614 | License | MIT Did you know that __sleep can return mangled property names? I didn't :) https://3v4l.org/3ckU7 Fixes doctrine/orm#11063 also. Commits ------- c5bd676 [VarExporter] Fix handling mangled property names returned by __sleep()
BC Break Report
Could not find anything in release notes so far that predicted this would break. Was also not yet able to determine which, if any, of the changes listed cause this behaviour. Will update this issue as I get further along.
Stacktrace is as follows (omitted a few lines at the bottom for brevity):
Summary
See stacktrace above.
Previous behavior
No exception was thrown.
Current behavior
Exception is thrown.
How to reproduce
Hard to tell, might be related to our code, might not be? Still debugging.
Update(s)
It seems that turning on lazy ghosts resolves the issue. However, that does not seem to be the default configuration in our symfony application. Is this the right way to deprecate something?Turning it back off does not break things. Looking more likely to be cache related, making this a non-issue. Will try a new deployment with some more rigorous cache purging.Sigh. Works on development environment now, broken on production still. More debugging needed.
The text was updated successfully, but these errors were encountered: