Skip to content

Commit

Permalink
bug #23469 [FrameworkBundle] do not wire namespaces for the ArrayAdap…
Browse files Browse the repository at this point in the history
…ter (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
  • Loading branch information
nicolas-grekas committed Jul 11, 2017
2 parents 2fc9bd2 + 9380614 commit 7fd5236
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -70,7 +71,7 @@ public function process(ContainerBuilder $container)
}
$i = 0;
foreach ($attributes as $attr) {
if (isset($tags[0][$attr])) {
if (isset($tags[0][$attr]) && ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass())) {
$pool->replaceArgument($i++, $tags[0][$attr]);
}
unset($tags[0][$attr]);
Expand Down
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
Expand Down Expand Up @@ -49,6 +50,24 @@ public function testNamespaceArgumentIsReplaced()
$this->assertSame('D07rhFx97S', $cachePool->getArgument(0));
}

public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.environment', 'prod');
$container->setParameter('kernel.name', 'app');
$container->setParameter('kernel.root_dir', 'foo');

$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);

$cachePool = new DefinitionDecorator('cache.adapter.array');
$cachePool->addTag('cache.pool');
$container->setDefinition('app.cache_pool', $cachePool);

$this->cachePoolPass->process($container);

$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
}

public function testArgsAreReplaced()
{
$container = new ContainerBuilder();
Expand Down

0 comments on commit 7fd5236

Please sign in to comment.