Skip to content

Commit 7fd5236

Browse files
bug #23469 [FrameworkBundle] do not wire namespaces for the ArrayAdapter (xabbuh)
This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] do not wire namespaces for the ArrayAdapter | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23214 | License | MIT | Doc PR | Commits ------- 9380614 do not wire namespaces for the ArrayAdapter
2 parents 2fc9bd2 + 9380614 commit 7fd5236

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1415
use Symfony\Component\Cache\Adapter\RedisAdapter;
1516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -70,7 +71,7 @@ public function process(ContainerBuilder $container)
7071
}
7172
$i = 0;
7273
foreach ($attributes as $attr) {
73-
if (isset($tags[0][$attr])) {
74+
if (isset($tags[0][$attr]) && ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass())) {
7475
$pool->replaceArgument($i++, $tags[0][$attr]);
7576
}
7677
unset($tags[0][$attr]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
16+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Definition;
1819
use Symfony\Component\DependencyInjection\DefinitionDecorator;
@@ -49,6 +50,24 @@ public function testNamespaceArgumentIsReplaced()
4950
$this->assertSame('D07rhFx97S', $cachePool->getArgument(0));
5051
}
5152

53+
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
54+
{
55+
$container = new ContainerBuilder();
56+
$container->setParameter('kernel.environment', 'prod');
57+
$container->setParameter('kernel.name', 'app');
58+
$container->setParameter('kernel.root_dir', 'foo');
59+
60+
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
61+
62+
$cachePool = new DefinitionDecorator('cache.adapter.array');
63+
$cachePool->addTag('cache.pool');
64+
$container->setDefinition('app.cache_pool', $cachePool);
65+
66+
$this->cachePoolPass->process($container);
67+
68+
$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
69+
}
70+
5271
public function testArgsAreReplaced()
5372
{
5473
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)