Description
Symfony version(s) affected: 4.3.*
Description
We noticed that in symfony/cache
a change is introduced for the seed/namespace in cache pools. This was done in symfony/cache@d8dda03
In that commit, the seed is suffixed with the class of the adapter. However, this is done in a for loop, so if a certain pool is added in the configuration before the previously defined pool, the original pool seed also changes. This is because the code now does something like: $seed .= '.'.$class;
. Every next pool will receive the classes of the previous pools, plus the adapter pool of the current one. This seems like a side effect that is not desirable. It seems something like this should fix that issue:
$namespaceSeed = $seed;
if (null !== $class) {
$namespaceSeed .= '.'.$class;
}
$tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);
That way, the seeds won't change if pools are added/removed. In our case we are leaning heavy on cache, so if adding an extra pool could cause major issues on deploys.
How to reproduce
Define a pool, eg:
framework:
cache:
app: cache.adapter.redis
default_redis_provider: "xxxxx"
prefix_seed: "some-seed"
pools:
cache.some_pool:
adapter: cache.adapter.redis
tags: true
Place a var dump in \Symfony\Component\Cache\DependencyInjection\CachePoolPass::process
after $tags[0]['namespace']
, eg: var_dump($id, $tags[0]['namespace'])
Run bin/console cache:clear
, this will trigger \Symfony\Component\Cache\DependencyInjection\CachePoolPass::process.
Copy the namespace for the pool cache.some_pool
Add an extra pool above cache.some_pool
in the configuration and run the bin/console cache:clear
again. See that the namespace for the original cache.some_pool
is also changed.
Possible Solution
See the possible solution at the top of this issue.
Additional context
na