Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] NullAdapter configuration in framework - Cannot replace arguments if none have been configured yet #42364

Closed
@olsavmic

Description

@olsavmic

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.

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