Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7cd9f93

Browse filesBrowse files
committed
[Cache] Fix possible infinite loop in CachePoolPass
1 parent 9d45d95 commit 7cd9f93
Copy full SHA for 7cd9f93

File tree

Expand file treeCollapse file tree

2 files changed

+34
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+34
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ public function process(ContainerBuilder $container)
209209
}
210210

211211
$notAliasedCacheClearerId = $this->cacheClearerId;
212-
while ($container->hasAlias($this->cacheClearerId)) {
213-
$this->cacheClearerId = (string) $container->getAlias($this->cacheClearerId);
212+
while ($container->hasAlias($notAliasedCacheClearerId)) {
213+
$notAliasedCacheClearerId = (string) $container->getAlias($notAliasedCacheClearerId);
214214
}
215-
if ($container->hasDefinition($this->cacheClearerId)) {
215+
if ($container->hasDefinition($notAliasedCacheClearerId)) {
216216
$clearers[$notAliasedCacheClearerId] = $allPools;
217217
}
218218

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
2121
use Symfony\Component\DependencyInjection\ChildDefinition;
2222
use Symfony\Component\DependencyInjection\ContainerBuilder;
23+
use Symfony\Component\DependencyInjection\ContainerInterface;
2324
use Symfony\Component\DependencyInjection\Definition;
2425
use Symfony\Component\DependencyInjection\Reference;
26+
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
2527

2628
class CachePoolPassTest extends TestCase
2729
{
@@ -232,4 +234,33 @@ public function testChainAdapterPool()
232234
$this->assertInstanceOf(ChildDefinition::class, $doctrineCachePool);
233235
$this->assertSame('cache.app', $doctrineCachePool->getParent());
234236
}
237+
238+
public function testGlobalClearerAlias()
239+
{
240+
$container = new ContainerBuilder();
241+
$container->setParameter('kernel.container_class', 'app');
242+
$container->setParameter('kernel.project_dir', 'foo');
243+
244+
$container->register('cache.default_clearer', Psr6CacheClearer::class);
245+
246+
$container->setDefinition('cache.system_clearer', new ChildDefinition('cache.default_clearer'));
247+
248+
$container->setDefinition('cache.foo_bar_clearer', new ChildDefinition('cache.default_clearer'));
249+
$container->setAlias('cache.global_clearer', 'cache.foo_bar_clearer');
250+
251+
$container->register('cache.adapter.array', ArrayAdapter::class)
252+
->setAbstract(true)
253+
->addTag('cache.pool');
254+
255+
$cachePool = new ChildDefinition('cache.adapter.array');
256+
$cachePool->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
257+
$container->setDefinition('app.cache_pool', $cachePool);
258+
259+
$this->cachePoolPass->process($container);
260+
261+
$definition = $container->getDefinition('cache.foo_bar_clearer');
262+
263+
$this->assertTrue($definition->hasTag('cache.pool.clearer'));
264+
$this->assertEquals(['app.cache_pool' => new Reference('app.cache_pool', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)], $definition->getArgument(0));
265+
}
235266
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.