From b24e3cd21ebe36cd1dc43e04b1fc77c16dc1734a Mon Sep 17 00:00:00 2001 From: Indra Gunawan Date: Fri, 30 May 2025 15:52:26 +0800 Subject: [PATCH] [Cache] Fix using a `ChainAdapter` as an adapter for a pool --- .../Component/Cache/DependencyInjection/CachePoolPass.php | 4 +++- .../Cache/Tests/DependencyInjection/CachePoolPassTest.php | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php index 90c089074ef4b..80b8a94c98152 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php @@ -58,9 +58,11 @@ public function process(ContainerBuilder $container) continue; } $class = $adapter->getClass(); + $providers = $adapter->getArguments(); while ($adapter instanceof ChildDefinition) { $adapter = $container->findDefinition($adapter->getParent()); $class = $class ?: $adapter->getClass(); + $providers += $adapter->getArguments(); if ($t = $adapter->getTag('cache.pool')) { $tags[0] += $t[0]; } @@ -90,7 +92,7 @@ public function process(ContainerBuilder $container) if (ChainAdapter::class === $class) { $adapters = []; - foreach ($adapter->getArgument(0) as $provider => $adapter) { + foreach ($providers['index_0'] ?? $providers[0] as $provider => $adapter) { if ($adapter instanceof ChildDefinition) { $chainedPool = $adapter; } else { diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php index eaf5929559ca6..a50792f67ad3a 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php @@ -209,7 +209,8 @@ public function testChainAdapterPool() $container->register('cache.adapter.apcu', ApcuAdapter::class) ->setArguments([null, 0, null]) ->addTag('cache.pool'); - $container->register('cache.chain', ChainAdapter::class) + $container->register('cache.adapter.chain', ChainAdapter::class); + $container->setDefinition('cache.chain', new ChildDefinition('cache.adapter.chain')) ->addArgument(['cache.adapter.array', 'cache.adapter.apcu']) ->addTag('cache.pool'); $container->setDefinition('cache.app', new ChildDefinition('cache.chain')) @@ -224,7 +225,7 @@ public function testChainAdapterPool() $this->assertSame('cache.chain', $appCachePool->getParent()); $chainCachePool = $container->getDefinition('cache.chain'); - $this->assertNotInstanceOf(ChildDefinition::class, $chainCachePool); + $this->assertInstanceOf(ChildDefinition::class, $chainCachePool); $this->assertCount(2, $chainCachePool->getArgument(0)); $this->assertInstanceOf(ChildDefinition::class, $chainCachePool->getArgument(0)[0]); $this->assertSame('cache.adapter.array', $chainCachePool->getArgument(0)[0]->getParent()); 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