Skip to content

Commit b24e3cd

Browse files
IndraGunawannicolas-grekas
authored andcommitted
[Cache] Fix using a ChainAdapter as an adapter for a pool
1 parent 341e1bf commit b24e3cd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ public function process(ContainerBuilder $container)
5858
continue;
5959
}
6060
$class = $adapter->getClass();
61+
$providers = $adapter->getArguments();
6162
while ($adapter instanceof ChildDefinition) {
6263
$adapter = $container->findDefinition($adapter->getParent());
6364
$class = $class ?: $adapter->getClass();
65+
$providers += $adapter->getArguments();
6466
if ($t = $adapter->getTag('cache.pool')) {
6567
$tags[0] += $t[0];
6668
}
@@ -90,7 +92,7 @@ public function process(ContainerBuilder $container)
9092

9193
if (ChainAdapter::class === $class) {
9294
$adapters = [];
93-
foreach ($adapter->getArgument(0) as $provider => $adapter) {
95+
foreach ($providers['index_0'] ?? $providers[0] as $provider => $adapter) {
9496
if ($adapter instanceof ChildDefinition) {
9597
$chainedPool = $adapter;
9698
} else {

src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public function testChainAdapterPool()
209209
$container->register('cache.adapter.apcu', ApcuAdapter::class)
210210
->setArguments([null, 0, null])
211211
->addTag('cache.pool');
212-
$container->register('cache.chain', ChainAdapter::class)
212+
$container->register('cache.adapter.chain', ChainAdapter::class);
213+
$container->setDefinition('cache.chain', new ChildDefinition('cache.adapter.chain'))
213214
->addArgument(['cache.adapter.array', 'cache.adapter.apcu'])
214215
->addTag('cache.pool');
215216
$container->setDefinition('cache.app', new ChildDefinition('cache.chain'))
@@ -224,7 +225,7 @@ public function testChainAdapterPool()
224225
$this->assertSame('cache.chain', $appCachePool->getParent());
225226

226227
$chainCachePool = $container->getDefinition('cache.chain');
227-
$this->assertNotInstanceOf(ChildDefinition::class, $chainCachePool);
228+
$this->assertInstanceOf(ChildDefinition::class, $chainCachePool);
228229
$this->assertCount(2, $chainCachePool->getArgument(0));
229230
$this->assertInstanceOf(ChildDefinition::class, $chainCachePool->getArgument(0)[0]);
230231
$this->assertSame('cache.adapter.array', $chainCachePool->getArgument(0)[0]->getParent());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy