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 50be214

Browse filesBrowse files
committed
bug #21556 [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap (nicolas-grekas)
This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21549 | License | MIT | Doc PR | - Related to #21381 which disabled any cache at bootstrap. Instead, this wires ArrayCache during bootstrapping, then swaps the cache provider for the real one. Commits ------- f90f53e [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap
2 parents f376080 + f90f53e commit 50be214
Copy full SHA for 50be214

File tree

4 files changed

+18
-3
lines changed
Filter options

4 files changed

+18
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Reference;
1617

1718
/**
1819
* @internal
@@ -27,7 +28,16 @@ public function process(ContainerBuilder $container)
2728
// "annotations.cached_reader" is wired late so that any passes using
2829
// "annotation_reader" at build time don't get any cache
2930
if ($container->hasDefinition('annotations.cached_reader')) {
30-
$container->setAlias('annotation_reader', 'annotations.cached_reader');
31+
$reader = $container->getDefinition('annotations.cached_reader');
32+
$tags = $reader->getTags();
33+
34+
if (isset($tags['annotations.cached_reader'][0]['provider'])) {
35+
if ($container->hasAlias($provider = $tags['annotations.cached_reader'][0]['provider'])) {
36+
$provider = (string) $container->getAlias($provider);
37+
}
38+
$container->set('annotations.cached_reader', null);
39+
$container->setDefinition('annotations.cached_reader', $reader->replaceArgument(1, new Reference($provider)));
40+
}
3141
}
3242
}
3343
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,11 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
10391039

10401040
$container
10411041
->getDefinition('annotations.cached_reader')
1042-
->replaceArgument(1, new Reference($cacheService))
10431042
->replaceArgument(2, $config['debug'])
1043+
->addTag('annotations.cached_reader', array('provider' => $cacheService))
10441044
->addAutowiringType(Reader::class)
10451045
;
1046+
$container->setAlias('annotation_reader', 'annotations.cached_reader');
10461047
} else {
10471048
$container->removeDefinition('annotations.cached_reader');
10481049
}

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
<service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader" public="false">
1313
<argument type="service" id="annotations.reader" />
14-
<argument /><!-- Cache Implementation -->
14+
<argument type="service">
15+
<service class="Doctrine\Common\Cache\ArrayCache" />
16+
</argument>
1517
<argument /><!-- Debug-Flag -->
1618
</service>
1719

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

1414
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
15+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
1516
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1617
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1718
use Symfony\Component\Cache\Adapter\ChainAdapter;
@@ -818,6 +819,7 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile
818819
$container->getCompilerPassConfig()->setOptimizationPasses(array());
819820
$container->getCompilerPassConfig()->setRemovingPasses(array());
820821
}
822+
$container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddAnnotationsCachedReaderPass()));
821823
$container->compile();
822824

823825
return self::$containerCache[$cacheKey] = $container;

0 commit comments

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