orm: Upgrading from 2.16.3 to 2.17.0 breaks serialization when using symfony/var-exporter
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):
TypeError:
Doctrine\DBAL\Connection::executeQuery(): Argument #1 ($sql) must be of type string, null given, called in /srv/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php on line 33
at vendor/doctrine/dbal/src/Connection.php:1071
at Doctrine\DBAL\Connection->executeQuery(null, array(), array(), null)
(vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php:33)
at Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(object(Connection), array(), array())
(vendor/doctrine/orm/lib/Doctrine/ORM/Query.php:327)
at Doctrine\ORM\Query->_doExecute()
(vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:1212)
at Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(null, 3)
(vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:1166)
at Doctrine\ORM\AbstractQuery->execute(null, 3)
(vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php:937)
at Doctrine\ORM\AbstractQuery->getScalarResult()
(vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php:153)
at Doctrine\ORM\Tools\Pagination\Paginator->getIterator()
at iterator_to_array(object(Paginator))
(src/<redacted>/Doctrine/Repository/CategoryRepository.php:46)
at <redacted>\Doctrine\Repository\CategoryRepository->getRootCategories(25, 0)
(src/<redacted>/CategoryBundle/Menu/MenuBuilder.php:119)
at <redacted>\CategoryBundle\Menu\MenuBuilder->getCategoryTreeMenu(object(MenuItem), true)
(src/<redacted>/CategoryBundle/Menu/MenuBuilder.php:114)
at <redacted>\CategoryBundle\Menu\MenuBuilder->createMobileCategoryMenu(object(RequestStack))
(var/cache/nl/docker/ContainerKpuxm9P/getPsCategory_Menu_MobileCategoriesService.php:23)
at ContainerKpuxm9P\getPsCategory_Menu_MobileCategoriesService::do(object(AppKernelDockerDebugContainer), true)
(var/cache/nl/docker/ContainerKpuxm9P/AppKernelDockerDebugContainer.php:898)
at ContainerKpuxm9P\AppKernelDockerDebugContainer->load('getPsCategory_Menu_MobileCategoriesService.php')
(var/cache/nl/docker/ContainerKpuxm9P/getKnpMenu_MenuProvider_LazyService.php:22)
at ContainerKpuxm9P\getKnpMenu_MenuProvider_LazyService::ContainerKpuxm9P\{closure}(array())
(vendor/knplabs/knp-menu/src/Knp/Menu/Provider/LazyProvider.php:39)
at Knp\Menu\Provider\LazyProvider->get('mobile_categories', array())
(vendor/knplabs/knp-menu/src/Knp/Menu/Provider/ChainProvider.php:26)
at Knp\Menu\Provider\ChainProvider->get('mobile_categories', array())
(vendor/knplabs/knp-menu/src/Knp/Menu/Twig/Helper.php:43)
at Knp\Menu\Twig\Helper->get('mobile_categories', array())
(vendor/knplabs/knp-menu/src/Knp/Menu/Twig/Helper.php:142)
at Knp\Menu\Twig\Helper->castMenu('mobile_categories')
(vendor/knplabs/knp-menu/src/Knp/Menu/Twig/Helper.php:75)
Q | A |
---|---|
BC Break | yes |
Version | 2.17.0 |
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.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 17
- Comments: 76 (66 by maintainers)
Commits related to this issue
- downgrade doctrine/orm https://github.com/doctrine/orm/issues/11063 — committed to Pushword/Pushword by RobinDev 7 months ago
- downgrade doctrine/orm https://github.com/doctrine/orm/issues/11063 — committed to Pushword/core by RobinDev 7 months ago
- bug #52618 [VarExporter] Fix handling mangled property names returned by __sleep() (nicolas-grekas) This PR was merged into the 5.4 branch. Discussion ---------- [VarExporter] Fix handling mangled ... — committed to symfony/symfony by nicolas-grekas 7 months ago
https://github.com/doctrine/orm/releases/tag/2.17.1 released
Fix for Symfony: https://github.com/symfony/symfony/pull/52618
Thank you all for the help on this one!
@greg0ire https://github.com/doctrine/orm/pull/11065
Hi. I have the same error. Reverting to 2.16.3 solves the problem.
Awesome, many thanks to everyone who got involved so quickly to resolve this 🥳 !
@szczyglis-dev I said: YOU JUST NEED TO WAIT
So just wait. No need for more reports.
On
2.16.3
it yields this file: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
doctrine/orm
orsymfony/var-exporter
.One could argue that this method should not return the properties with their internal visibility names, but as @greg0ire mentioned before, get_object_vars is not an option in this case as this will skip the private properties of subclasses. Using Reflection is another option, but I’m not sure if that’s the best option in this case neither 😕
@nicolas-grekas in short, this is the problem:
The (array) $this returns the properties with the internal visibility names, which does not work with VarExporter.
Returning those properties with the internal visibility names and executing serialize on it will work however.
From what I can tell though, it breaks on production when storing and retrieving the
ParserResult
instance. So production works on first deploy (no cache). Then as soon as cache items get generated, things break.The
PhpFilesAdapter
usesVarExporter
.The result of
VarExporter::export
inPhpFilesAdapter
with my change:Result of unmodified code:
Notice the missing
sqlStatements
key.You can check this by dumping the result of
VarExporter::export
inPhpFilesAdapter
on line 227@greg0ire Yes, I’m aware of the fact that it governs what to serialize. I’m switching to
get_object_vars
to get rid of the \0x\0 prefixes, which I thought was causing the issue.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
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.
For me it was resolved by purging our cache more explicitly.