Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db7ec1c

Browse files
[FrameworkBundle] fix wiring of annotations.cached_reader
1 parent f3df3d0 commit db7ec1c

File tree

9 files changed

+17
-12
lines changed

9 files changed

+17
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/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'])) {

src/Symfony/Bundle/FrameworkBundle/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',

src/Symfony/Bundle/FrameworkBundle/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);

src/Symfony/Bundle/FrameworkBundle/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">

src/Symfony/Bundle/FrameworkBundle/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',

src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public function process(ContainerBuilder $container)
4040
}
4141
$decoratingDefinitions = [];
4242

43+
$tagsToKeep = $container->hasParameter('container.behavior_describing_tags')
44+
? $container->getParameter('container.behavior_describing_tags')
45+
: ['container.do_not_inline', 'container.service_locator', 'container.service_subscriber'];
46+
4347
foreach ($definitions as [$id, $definition]) {
4448
$decoratedService = $definition->getDecoratedService();
4549
[$inner, $renamedId] = $decoratedService;
@@ -89,8 +93,8 @@ public function process(ContainerBuilder $container)
8993
$decoratingTags = $decoratingDefinition->getTags();
9094
$resetTags = [];
9195

92-
// container.service_locator and container.service_subscriber have special logic and they must not be transferred out to decorators
93-
foreach (['container.service_locator', 'container.service_subscriber'] as $containerTag) {
96+
// Behavior-describing tags must not be transferred out to decorators
97+
foreach ($tagsToKeep as $containerTag) {
9498
if (isset($decoratingTags[$containerTag])) {
9599
$resetTags[$containerTag] = $decoratingTags[$containerTag];
96100
unset($decoratingTags[$containerTag]);

src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function processValue($value, $isRoot = false)
177177
*/
178178
private function isInlineableDefinition(string $id, Definition $definition): bool
179179
{
180-
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic()) {
180+
if ($definition->hasErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic() || $definition->hasTag('container.do_not_inline')) {
181181
return false;
182182
}
183183

src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ public function process(ContainerBuilder $container)
4141
$this->enableExpressionProcessing();
4242
$this->container = $container;
4343
$connectedIds = [];
44-
$aliases = $container->getAliases();
4544

46-
foreach ($aliases as $id => $alias) {
47-
if ($alias->isPublic()) {
48-
$this->connectedIds[] = (string) $aliases[$id];
49-
}
45+
foreach ($container->getAliases() as $alias) {
46+
$this->connectedIds[] = (string) $alias;
5047
}
5148

5249
foreach ($container->getDefinitions() as $id => $definition) {

src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function process(ContainerBuilder $container)
6161

6262
throw $e;
6363
}
64-
if ($definition->isPublic()) {
64+
if ($definition->isPublic() || $definition->hasTag('container.do_not_inline')) {
6565
continue;
6666
}
6767
// Remove private definition and schedule for replacement

0 commit comments

Comments
 (0)