Closed
Description
Symfony version(s) affected: 5.*, 4.*
Description
Defining custom adapter cache.adapter.null as a service and then using it as an adapter for cache pool fails with error
Cannot replace arguments if none have been configured yet.
The error occurs due to CachePoolPass adding a namespace argument to the child definition tagged with cache.pool
tag.
./vendor/symfony/dependency-injection/Definition.php:268 { …}
./vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:176 { …}
./vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:62 { …}
./vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:45 { …}
./vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:81 { …}
./vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:36 { …}
./vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:46 { …}
./vendor/symfony/dependency-injection/Compiler/Compiler.php:91 { …}
./vendor/symfony/dependency-injection/ContainerBuilder.php:749 { …}
./vendor/symfony/http-kernel/Kernel.php:545 { …}
./vendor/symfony/http-kernel/Kernel.php:786 { …}
./vendor/symfony/http-kernel/Kernel.php:125 { …}
./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
./vendor/symfony/console/Application.php:167 { …}
services.yaml
cache.adapter.null:
class: Symfony\Component\Cache\Adapter\NullAdapter
config.yaml
framework:
cache:
pools:
cache.pool.doctrine.orm.result:
adapter: cache.adapter.null
Possible Solution
Quick fix:
cache.adapter.null:
class: Symfony\Component\Cache\Adapter\NullAdapter
arguments: [~]
-> Add artificial null argument that will be replaced (and not used during construction) in definition.
Solution:
Patch CachePoolPass for NullAdapter the same way it handles namespace argument for ArrayAdapter.