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 4a866d0

Browse filesBrowse files
bug symfony#33570 Fixed cache pools affecting each other due to an overwritten seed variable (roed)
This PR was merged into the 4.3 branch. Discussion ---------- Fixed cache pools affecting each other due to an overwritten seed variable | Q | A | ------------- | --- | Branch? | 4.3 for bug fixes | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#33561 | License | MIT Due to the fact the adapter was added to the cache seed calculation for cache pools, multiple pool definitions could affect each other. The how and why is described in symfony#33561. This PR resolves that issue by using a copy of the seed and mutating only that copy. Commits ------- 29ba7a8 Fixed cache pools affecting each other due to an overwritten seed variable
2 parents 5914a1f + 29ba7a8 commit 4a866d0
Copy full SHA for 4a866d0

File tree

Expand file treeCollapse file tree

2 files changed

+30
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ public function process(ContainerBuilder $container)
7878
}
7979
$name = $tags[0]['name'] ?? $id;
8080
if (!isset($tags[0]['namespace'])) {
81+
$namespaceSeed = $seed;
8182
if (null !== $class) {
82-
$seed .= '.'.$class;
83+
$namespaceSeed .= '.'.$class;
8384
}
8485

85-
$tags[0]['namespace'] = $this->getNamespace($seed, $name);
86+
$tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);
8687
}
8788
if (isset($tags[0]['clearer'])) {
8889
$clearer = $tags[0]['clearer'];

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,33 @@ public function testNamespaceArgumentIsSeededWithAdapterClassName()
7070
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
7171
}
7272

73+
public function testNamespaceArgumentIsSeededWithAdapterClassNameWithoutAffectingOtherCachePools()
74+
{
75+
$container = new ContainerBuilder();
76+
$container->setParameter('kernel.container_class', 'app');
77+
$container->setParameter('kernel.project_dir', 'foo');
78+
$adapter = new Definition();
79+
$adapter->setAbstract(true);
80+
$adapter->addTag('cache.pool');
81+
$adapter->setClass(RedisAdapter::class);
82+
$container->setDefinition('app.cache_adapter', $adapter);
83+
$container->setAlias('app.cache_adapter_alias', 'app.cache_adapter');
84+
85+
$otherCachePool = new ChildDefinition('app.cache_adapter_alias');
86+
$otherCachePool->addArgument(null);
87+
$otherCachePool->addTag('cache.pool');
88+
$container->setDefinition('app.other_cache_pool', $otherCachePool);
89+
90+
$cachePool = new ChildDefinition('app.cache_adapter_alias');
91+
$cachePool->addArgument(null);
92+
$cachePool->addTag('cache.pool');
93+
$container->setDefinition('app.cache_pool', $cachePool);
94+
95+
$this->cachePoolPass->process($container);
96+
97+
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
98+
}
99+
73100
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
74101
{
75102
$container = new ContainerBuilder();

0 commit comments

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