The Wayback Machine - https://web.archive.org/web/20250611042027/https://github.com/symfony/symfony/issues/58864
Skip to content

[Cache] Cache pool with provider key can not be overriden in tests environment and failes with OutOfBoundsException #58864

Open
@sidz

Description

@sidz

Symfony version(s) affected

7.1

Description

Cache clear fails on test environment when one of the cache pool uses non-default provider and defined cache pool is overridden with cache.adapter.array adapter which doesn't support provider key.

I didn't check lower versions but I think it's actual for any supported symfony version.

How to reproduce

cache.yaml

framework:
    cache:
        default_redis_provider: '%env(REDIS_DSN)%'

        pools:
            cache.my_cache:
                adapter: cache.adapter.redis
                provider: '%env(REDIS_CUSTOM_DSN)%'
                default_lifetime: '%env(LIFETIME)%'

when@test:
    framework:
        cache:
            pools:
                cache.my_cache:
                    adapter: cache.adapter.array

Run bin/console ca:cl -e test

14c7a6e7ae7c:/app# bin/console ca:cl -e test -vv

In Definition.php line 261:
                                                                                                                      
  [Symfony\Component\DependencyInjection\Exception\OutOfBoundsException]                                              
  Service "cache.my_cache": The argument "1" doesn't exist in class "Symfony\Component\Cache\Adapter\ArrayAdapter".  
                                                                                                                      

Exception trace:
  at /app/vendor/symfony/dependency-injection/Definition.php:261
 Symfony\Component\DependencyInjection\Definition->replaceArgument() at /app/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:167
 Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass->doResolveDefinition() at /app/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:63
 Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass->resolveDefinition() at /app/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:46
 Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:84
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php:37
 Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass->processValue() at /app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:45
 Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->process() at /app/vendor/symfony/dependency-injection/Compiler/Compiler.php:73
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /app/vendor/symfony/dependency-injection/ContainerBuilder.php:752
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /app/vendor/symfony/http-kernel/Kernel.php:495
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /app/vendor/symfony/http-kernel/Kernel.php:740
 Symfony\Component\HttpKernel\Kernel->preBoot() at /app/vendor/symfony/http-kernel/Kernel.php:120
 Symfony\Component\HttpKernel\Kernel->boot() at /app/vendor/symfony/framework-bundle/Console/Application.php:177
 Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() at /app/vendor/symfony/framework-bundle/Console/Application.php:69
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /app/vendor/autoload_runtime.php:29
 require_once() at /app/bin/console:11

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions