8000 [Cache] Error when using cache chain as adapter · Issue #35119 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Error when using cache chain as adapter #35119

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

Closed
Nyholm opened this issue Dec 27, 2019 · 1 comment
Closed

[Cache] Error when using cache chain as adapter #35119

Nyholm opened this issue Dec 27, 2019 · 1 comment

Comments

@Nyholm
Copy link
Member
Nyholm commented Dec 27, 2019

Symfony version(s) affected: 4.4.x and 5.0.x

Description
When using a cache chain as an adapter we get an error when building the container.

How to reproduce

framework:
    cache:
        app: cache.chain
        pools:
            cache.chain:
                adapters:
                    - cache.adapter.array
                    - cache.adapter.apcu


            doctrine.result_cache_pool:
                adapter: cache.app

When warming up the cache we will get:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Symfony\Component\DependencyInjection\ChildDefinition::__construct() must be of the type string, object given, called in /project/vendor/symfony/cache/DependencyInjection/CachePoolPass.php on line 106 and defined in /project/vendor/symfony/dependency-injection/ChildDefinition.php:30
Stack trace:
#0 /project/vendor/symfony/cache/DependencyInjection/CachePoolPass.php(106): Symfony\Component\DependencyInjection\ChildDefinition->__construct(Object(Symfony\Component\DependencyInjection\ChildDefinition))
#1 /project/vendor/symfony/dependency-injection/Compiler/Compiler.php(91): Symfony\Component\Cache\DependencyInjection\CachePoolPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 /project/vendor/symfony/dependency-injection/ContainerBuilder.php(734): Symfony\Component\Dependency in /project/vendor/symfony/dependency-injection/ChildDefinition.php on line 30

Possible Solution

I have no possible solution at the moment.

Additional context

This could happen if you define your cache chain as cache.app (which I believe you should). Then other cache pools like the ones used by Doctrine will complain. A workaround is to tell doctrine to use another (non-chain) cache pool.

# config/packages/prod/doctrine.yaml
# ...
framework:
    cache:
        pools:
            doctrine.result_cache_pool:
                adapter: cache.redis_pool
            doctrine.system_cache_pool:
                adapter: cache.system
@xabbuh
8DFE
Copy link
Member
xabbuh commented Jan 7, 2020

a possible fix is #35244

@fabpot fabpot closed this as completed Jan 7, 2020
fabpot added a commit that referenced this issue Jan 7, 2020
…buh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] fix processing chain adapter based cache pool

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35119
| License       | MIT
| Doc PR        |

Commits
-------

8d7fa32 fix processing chain adapter based cache pool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0