DoctrineBundle: second level cache is broken
DoctrineBundle affected: 2.4.1
Description
After the сomposer update
and updates doctrine/doctrine-bundles
to 2.4, there is a fatal error.
Before updating the error package was not.
How to reproduce
// config/packages/cache.yaml
framework:
cache:
# Redis
app: cache.adapter.redis_tag_aware
default_redis_provider: redis://localhost
// config/packages/doctrine_second_cache.yaml
doctrine:
orm:
second_level_cache:
enabled: true
region_cache_driver:
type: pool
pool: doctrine.second_level_cache_pool
framework:
cache:
pools:
doctrine.second_level_cache_pool:
adapter: cache.app
default_lifetime: 60
Additional context
$ bin/console cache:clear
TypeError {#568
#message: "Argument 2 passed to Doctrine\ORM\Cache\DefaultCacheFactory::__construct() must implement interface Doctrine\Common\Cache\Cache, instance of Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter given, called in /tmp/sf5.2/var/cache/dev/ContainerVpzExal/App_KernelDevDebugContainer.php on line 665"
#code: 0
#file: "./vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php"
#line: 65
trace: {
./vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php:65 { …}
./var/cache/dev/ContainerVpzExal/App_KernelDevDebugContainer.php:665 {
ContainerVpzExal\App_KernelDevDebugContainer->getDoctrine_Orm_DefaultEntityManagerService($lazyLoad = true)^
› $b->setCacheLogger($c);
› $b->setCacheFactory(new \Doctrine\ORM\Cache\DefaultCacheFactory($d, ($this->privates['doctrine.second_level_cache_pool'] ?? $this->getDoctrine_SecondLevelCachePoolService())));
› $b->setRegionsConfiguration($d);
}
./var/cache/dev/ContainerVpzExal/App_KernelDevDebugContainer.php:612 { …}
./var/cache/dev/ContainerVpzExal/EntityManager_9a5be93.php:239 { …}
./var/cache/dev/ContainerVpzExal/EntityManager_9a5be93.php:239 { …}
./vendor/symfony/doctrine-bridge/CacheWarmer/ProxyCacheWarmer.php:54 { …}
./vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:98 { …}
./vendor/symfony/http-kernel/Kernel.php:580 { …}
./vendor/symfony/http-kernel/Kernel.php:780 { …}
./vendor/symfony/http-kernel/Kernel.php:121 { …}
./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
./vendor/symfony/console/Application.php:166 { …}
./bin/console:43 { …}
}
}
2021-06-01T20:38:15+00:00 [critical] Uncaught Error: Argument 2 passed to Doctrine\ORM\Cache\DefaultCacheFactory::__construct() must implement interface Doctrine\Common\Cache\Cache, instance of Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter given, called in /tmp/sf5.2/var/cache/dev/ContainerVpzExal/App_KernelDevDebugContainer.php on line 665
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 15 (9 by maintainers)
We’ll have 2.4.2 out soon. It’s a holiday, so you’ll have to excuse me spending the day in the sun. Thanks for all the positivity here, we appreciate it!
Thanks for providing the config. We’ll investigate this.
I’ve managed to reproduce this and will have a fix shortly.
when can you release the fix ?
Thanks @alcaeus for fixing it, but also thank you @Ne-Lexa for reporting it, I was just about to and you saved me some work there! ❤️
Yes, I installed the version
2.4.x-dev#bc6fc27dda3c8edad6189298e9a7eb7c99c87d55
and the error disappeared.When can I expect a release version 2.4.2? Thanks.
In case someone would like to try, there is a fix at https://github.com/doctrine/DoctrineBundle/pull/1397
I did the following workaround (we have policy to not use development versions): I’ve created a factory service (named:
doctrine.cache.second_level
) using theDoctrine\Common\Cache\Psr6\DoctrineProvider::wrap
and the symfony cache poolcache.doctrine.second_level
as the subject (which is originally created for second level cache).All can be reverted back with the release of 2.4.2, however it should work even after.
@Ne-Lexa can you please check if #1365 fixes this issue for you? Thanks!