8000 bug #46427 [FrameworkBundle] fix wiring of annotations.cached_reader … · symfony/framework-bundle@6eee263 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6eee263

Browse files
bug #46427 [FrameworkBundle] fix wiring of annotations.cached_reader (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] fix wiring of annotations.cached_reader | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46202 | License | MIT | Doc PR | - Also fixes symfony/symfony#26088 (comment) Instead of trying to hack the compilation of the container to prevent it from inlining `annotations.cached_reader`, this PR relies on an `container.do_not_inline` tag that just does that, prevent inlining so that removing passes can reliably fetch the corresponding services from the container by id or by tag. Commits ------- e32b7b15ec [FrameworkBundle] fix wiring of annotations.cached_reader
2 parents 6710e8d + c6b9863 commit 6eee263

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function process(ContainerBuilder $container)
2929
// "annotation_reader" at build time don't get any cache
3030
foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
3131
$reader = $container->getDefinition($id);
32-
$reader->setPublic(false);
3332
$properties = $reader->getProperties();
3433

3534
if (isset($properties['cacheProviderBackup'])) {

DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class UnusedTagsPass implements CompilerPassInterface
2828
'cache.pool.clearer',
2929
'config_cache.resource_checker',
3030
'console.command',
31+
'container.do_not_inline',
3132
'container.env_var_loader',
3233
'container.env_var_processor',
3334
'container.hot_path',

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ public function load(array $configs, ContainerBuilder $container)
469469
->addTag('routing.route_loader');
470470

471471
$container->setParameter('container.behavior_describing_tags', [
472+
'annotations.cached_reader',
473+
'container.do_not_inline',
472474
'container.service_locator',
473475
'container.service_subscriber',
474476
'kernel.event_subscriber',
@@ -1463,11 +1465,9 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14631465

14641466
$container
14651467
->getDefinition('annotations.cached_reader')
1466-
->setPublic(true) // set to false in AddAnnotationsCachedReaderPass
14671468
->replaceArgument(2, $config['debug'])
14681469
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
14691470
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
1470-
->addTag('annotations.cached_reader')
14711471
;
14721472

14731473
$container->setAlias('annotation_reader', 'annotations.cached_reader')->setPrivate(true);

Resources/config/annotations.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
</service>
3232
</argument>
3333
<argument /><!-- Debug-Flag -->
34+
<tag name="annotations.cached_reader" />
35+
<tag name="container.do_not_inline" />
3436
</service>
3537

3638
<service id="annotations.filesystem_cache_adapter" class="Symfony\Component\Cache\Adapter\FilesystemAdapter">

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,8 @@ public function testRegisterParameterCollectingBehaviorDescribingTags()
16991699

17001700
$this->assertTrue($container->hasParameter('container.behavior_describing_tags'));
17011701
$this->assertEquals([
1702+
'annotations.cached_reader',
1703+
'container.do_not_inline',
17021704
'container.service_locator',
17031705
'container.service_subscriber',
17041706
'kernel.event_subscriber',

0 commit comments

Comments
 (0)
0