Skip to content
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

Unit Of Work - entityIdentifiers Missing on cached OneToOne associations? #7759

Open
mverijdt opened this issue Jun 25, 2019 · 5 comments
Open
Assignees
Labels

Comments

@mverijdt
Copy link

Bug Report

Q A
BC Break Yes, I think so
Version 2.6.3

Summary

Doctrine ORM is throwing Exceptions in UnitOfWork related to DefaultEntityCache

Current behavior

These are the errors:

prod environment:

error: {
    message: "Argument 2 passed to Doctrine\ORM\Cache\EntityCacheKey::__construct() must be of the type array, null given, called in /var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php on line 353",
	trace: [
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/EntityCacheKey.php:49",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:353",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:305",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:426",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:181",
		"/var/www/myproject/vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntityValidator.php:139",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:809",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:525",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:330",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:141",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveValidator.php:100",
		"/var/www/myproject/src/Service/Api/Import/StoreImporter.php:251",
		"/var/www/myproject/src/Command/Api/Import/StoreImporterCommand.php:92",
		"/var/www/myproject/vendor/symfony/console/Command/Command.php:255",
		"/var/www/myproject/vendor/symfony/console/Application.php:926",
		"/var/www/myproject/vendor/symfony/framework-bundle/Console/Application.php:89",
		"/var/www/myproject/vendor/symfony/console/Application.php:269",
		"/var/www/myproject/vendor/symfony/framework-bundle/Console/Application.php:75",
		"/var/www/myproject/vendor/symfony/console/Application.php:145",
		"/var/www/myproject/bin/console:39"
	]
},

dev environment:

error: {
	message: "Notice: Undefined index: 0000000051f7928f000000005709f6ca",
	trace: [
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:2995",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:352",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:305",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:426",
		"/var/www/myproject/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:181",
		"/var/www/myproject/vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntityValidator.php:139",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:809",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:525",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:330",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:141",
		"/var/www/myproject/vendor/symfony/validator/Validator/RecursiveValidator.php:100",
		"/var/www/myproject/vendor/symfony/validator/Validator/TraceableValidator.php:66",
		"/var/www/myproject/vendor/liip/functional-test-bundle/src/Validator/DataCollectingValidator.php:66",
		"/var/www/myproject/src/Service/Api/Import/DeviceImporter.php:272",
		"/var/www/myproject/src/Command/Api/Import/DeviceImporterCommand.php:92",
		"/var/www/myproject/vendor/symfony/console/Command/Command.php:255",
		"/var/www/myproject/vendor/symfony/console/Application.php:926",
		"/var/www/myproject/vendor/symfony/framework-bundle/Console/Application.php:89",
		"/var/www/myproject/vendor/symfony/console/Application.php:269",
		"/var/www/myproject/vendor/symfony/framework-bundle/Console/Application.php:75",
		"/var/www/myproject/vendor/symfony/console/Application.php:145",
		"/var/www/myproject/bin/console:39"
	]
}

How to reproduce

Reproducing the problem is also a problem, see this repository

Expected behavior

I'd expect that the UnitOfWork would be able to find an entityIdentifier for OneToOne associations

A little more information and context

I've tried to explain this issue at stackoverflow

I'm not sure if it's L2 cache, it could also be Query Cache. but it has to be some sort of cache, when I disable all cache configuration in the application my Importer commands work perfectly together with all other components. Even the symfony/validation component which is the last component added when the errors started occuring

One other thing, this might be related to this issue or any of the other issues reported with One To One associations and

@lcobucci
Copy link
Member

lcobucci commented Oct 2, 2019

@maarten-shop4 I believe this should be solved by #7778, would you be able to update to v2.6.4 and try it out?

@nicodemuz
Copy link

@lcobucci I just updated to v2.6.4 and I'm also experiencing this issue.

@lcobucci
Copy link
Member

lcobucci commented Oct 2, 2019

@MrNicodemuz interesting, would you be up for sending us a PR with a failing functional test? That should help us a lot to identify and fix the issue.

@nicodemuz
Copy link

nicodemuz commented Oct 2, 2019

@lcobucci Here is a stack trace to begin with, not sure if it will be helpful:

In UnitOfWork.php line 2997:

  [ErrorException]
  Notice: Undefined index: 000000003c43dfef0000000028496ab9


Exception trace:
  at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:2997
 Doctrine\ORM\UnitOfWork->getEntityIdentifier() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:575
 Doctrine\ORM\Persisters\Entity\BasicEntityPersister->delete() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1188
 Doctrine\ORM\UnitOfWork->executeDeletions() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:411
 Doctrine\ORM\UnitOfWork->commit() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:359
 Doctrine\ORM\EntityManager->flush() at /Users/Nico/Projects/lms-platform/symfony/src/EventListener/TagLinkRemovalListener.php:74
 App\EventListener\TagLinkRemovalListener->handleTagCount() at /Users/Nico/Projects/lms-platform/symfony/src/EventListener/TagLinkRemovalListener.php:41
 App\EventListener\TagLinkRemovalListener->postRemove() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/doctrine-bridge/ContainerAwareEventManager.php:55
 Symfony\Bridge\Doctrine\ContainerAwareEventManager->dispatchEvent() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php:117
 Doctrine\ORM\Event\ListenersInvoker->invoke() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1205
 Doctrine\ORM\UnitOfWork->executeDeletions() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:411
 Doctrine\ORM\UnitOfWork->commit() at /Users/Nico/Projects/lms-platform/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:359
 Doctrine\ORM\EntityManager->flush() at /Users/Nico/Projects/lms-platform/symfony/src/Manager/YoutubeManager.php:495
 App\Manager\YoutubeManager->removeYoutubeVideo() at /Users/Nico/Projects/lms-platform/symfony/src/Service/YoutubeSyncService.php:217
 App\Service\YoutubeSyncService->deleteOldVideos() at /Users/Nico/Projects/lms-platform/symfony/src/Command/YoutubeSyncCommand.php:82
 App\Command\YoutubeSyncCommand->handleSync() at /Users/Nico/Projects/lms-platform/symfony/src/Command/YoutubeSyncCommand.php:62
 App\Command\YoutubeSyncCommand->execute() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/console/Application.php:933
 Symfony\Component\Console\Application->doRunCommand() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/framework-bundle/Console/Application.php:87
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/console/Application.php:272
 Symfony\Component\Console\Application->doRun() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/framework-bundle/Console/Application.php:73
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/Nico/Projects/lms-platform/symfony/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /Users/Nico/Projects/lms-platform/symfony/bin/console:46

@lcobucci
Copy link
Member

lcobucci commented Oct 2, 2019

The stack is not really helpful, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants