Fixed cache pools affecting each other due to an overwritten seed variable
This commit is contained in:
parent
5914a1fdef
commit
29ba7a8cf1
@ -78,11 +78,12 @@ class CachePoolPass implements CompilerPassInterface
|
|||||||
}
|
}
|
||||||
$name = $tags[0]['name'] ?? $id;
|
$name = $tags[0]['name'] ?? $id;
|
||||||
if (!isset($tags[0]['namespace'])) {
|
if (!isset($tags[0]['namespace'])) {
|
||||||
|
$namespaceSeed = $seed;
|
||||||
if (null !== $class) {
|
if (null !== $class) {
|
||||||
$seed .= '.'.$class;
|
$namespaceSeed .= '.'.$class;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags[0]['namespace'] = $this->getNamespace($seed, $name);
|
$tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);
|
||||||
}
|
}
|
||||||
if (isset($tags[0]['clearer'])) {
|
if (isset($tags[0]['clearer'])) {
|
||||||
$clearer = $tags[0]['clearer'];
|
$clearer = $tags[0]['clearer'];
|
||||||
|
@ -70,6 +70,33 @@ class CachePoolPassTest extends TestCase
|
|||||||
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
|
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNamespaceArgumentIsSeededWithAdapterClassNameWithoutAffectingOtherCachePools()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
|
$adapter = new Definition();
|
||||||
|
$adapter->setAbstract(true);
|
||||||
|
$adapter->addTag('cache.pool');
|
||||||
|
$adapter->setClass(RedisAdapter::class);
|
||||||
|
$container->setDefinition('app.cache_adapter', $adapter);
|
||||||
|
$container->setAlias('app.cache_adapter_alias', 'app.cache_adapter');
|
||||||
|
|
||||||
|
$otherCachePool = new ChildDefinition('app.cache_adapter_alias');
|
||||||
|
$otherCachePool->addArgument(null);
|
||||||
|
$otherCachePool->addTag('cache.pool');
|
||||||
|
$container->setDefinition('app.other_cache_pool', $otherCachePool);
|
||||||
|
|
||||||
|
$cachePool = new ChildDefinition('app.cache_adapter_alias');
|
||||||
|
$cachePool->addArgument(null);
|
||||||
|
$cachePool->addTag('cache.pool');
|
||||||
|
$container->setDefinition('app.cache_pool', $cachePool);
|
||||||
|
|
||||||
|
$this->cachePoolPass->process($container);
|
||||||
|
|
||||||
|
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
|
||||||
|
}
|
||||||
|
|
||||||
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
|
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
Reference in New Issue
Block a user