Skip to content

Commit 320d5f2

Browse files
bug #42445 [Cache] fix wiring async cache recomputing in debug mode (nicolas-grekas)
This PR was merged into the 5.3 branch. Discussion ---------- [Cache] fix wiring async cache recomputing in debug mode | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #42408 | License | MIT | Doc PR | - Commits ------- db60d1f [Cache] fix wiring async cache recomputing in debug mode
2 parents 5aff394 + db60d1f commit 320d5f2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ private function addToCollector(string $id, string $name, ContainerBuilder $cont
7272
}
7373
$recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]);
7474

75+
foreach ($definition->getMethodCalls() as [$method, $args]) {
76+
if ('setCallbackWrapper' !== $method || !$args[0] instanceof Definition || !($args[0]->getArguments()[2] ?? null) instanceof Definition) {
77+
continue;
78+
}
79+
if ([new Reference($id), 'setCallbackWrapper'] == $args[0]->getArguments()[2]->getFactory()) {
80+
$args[0]->getArguments()[2]->setFactory([new Reference($innerId), 'setCallbackWrapper']);
81+
}
82+
}
83+
7584
$definition->setTags([]);
7685
$definition->setPublic(false);
7786

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
2323
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
2424
use Symfony\Component\DependencyInjection\ContainerBuilder;
25+
use Symfony\Component\DependencyInjection\Definition;
2526
use Symfony\Component\DependencyInjection\Reference;
2627

2728
class CacheCollectorPassTest extends TestCase
@@ -31,6 +32,13 @@ public function testProcess()
3132
$container = new ContainerBuilder();
3233
$container
3334
->register('fs', FilesystemAdapter::class)
35+
->addMethodCall('setCallbackWrapper', [(new Definition())
36+
->addArgument(null)
37+
->addArgument(null)
38+
->addArgument((new Definition('callable'))
39+
->setFactory([new Reference('fs'), 'setCallbackWrapper'])
40+
),
41+
])
3442
->addTag('cache.pool');
3543
$container
3644
->register('tagged_fs', TagAwareAdapter::class)
@@ -60,6 +68,9 @@ public function testProcess()
6068
$this->assertSame(TagAwareAdapter::class, $container->getDefinition('php')->getClass());
6169

6270
$this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing');
71+
72+
$innerFs = $container->getDefinition('fs.recorder_inner');
73+
$this->assertEquals([new Reference('fs.recorder_inner'), 'setCallbackWrapper'], $innerFs->getMethodCalls()[0][1][0]->getArgument(2)->getFactory());
6374
}
6475

6576
public function testProcessCacheObjectsAreDecorated()

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