Skip to content

Commit cf52706

Browse files
Merge branch '3.2'
* 3.2: (27 commits) Improve tracking of environment variables in the case of private services [DI] Align AutowirePass with 2.8 property constraints can be added in child classes added test for staticClassLoader in LazyLoadingMetadatafactory fixed PHPUnit setUp and tearDown method visibility spelling fixes Readd Symfony version status in the toolbar [Security] LdapUserProvider should not throw an exception if the UID key does not exist in an LDAP entry make sure that null can be the invalid value [VarDumper] Improve dump of AMQP* Object Fix annotations cache folder path [FrameworkBundle] Wire ArrayCache for annotation reader at bootstrap Ignore missing 'debug.file_link_formatter' service in Debug bundle [VarDumper] Fixed dumping of terminated generator bumped Symfony version to 3.2.4 updated VERSION for 3.2.3 updated CHANGELOG for 3.2.3 bumped Symfony version to 2.8.18 updated VERSION for 2.8.17 updated CHANGELOG for 2.8.17 ...
2 parents ee4fd51 + 60359a6 commit cf52706

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Lines 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
}

DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -796,23 +796,14 @@ private function createPackageDefinition($basePath, array $baseUrls, Reference $
796796
throw new \LogicException('An asset package cannot have base URLs and base paths.');
797797
}
798798

799-
if (!$baseUrls) {
800-
$package = new ChildDefinition('assets.path_package');
801-
802-
return $package
803-
->setPublic(false)
804-
->replaceArgument(0, $basePath)
805-
->replaceArgument(1, $version)
806-
;
807-
}
808-
809-
$package = new ChildDefinition('assets.url_package');
810-
811-
return $package
799+
$package = new ChildDefinition($baseUrls ? 'assets.url_package' : 'assets.path_package');
800+
$package
812801
->setPublic(false)
813-
->replaceArgument(0, $baseUrls)
802+
->replaceArgument(0, $baseUrls ?: $basePath)
814803
->replaceArgument(1, $version)
815804
;
805+
806+
return $package;
816807
}
817808

818809
private function createVersion(ContainerBuilder $container, $version, $format, $name)
@@ -1084,9 +1075,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
10841075

10851076
$container
10861077
->getDefinition('annotations.cached_reader')
1087-
->replaceArgument(1, new Reference($cacheService))
10881078
->replaceArgument(2, $config['debug'])
1079+
->addTag('annotations.cached_reader', array('provider' => $cacheService))
10891080
;
1081+
$container->setAlias('annotation_reader', 'annotations.cached_reader');
10901082
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
10911083
} else {
10921084
$container->removeDefinition('annotations.cached_reader');
@@ -1276,7 +1268,6 @@ private function registerPropertyInfoConfiguration(array $config, ContainerBuild
12761268
private function registerCacheConfiguration(array $config, ContainerBuilder $container)
12771269
{
12781270
$version = substr(str_replace('/', '-', base64_encode(hash('sha256', uniqid(mt_rand(), true), true))), 0, 22);
1279-
$container->getDefinition('cache.annotations')->replaceArgument(2, $version);
12801271
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
12811272
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
12821273
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);

Resources/config/annotations.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

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

Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TemplatePathsCacheWarmerTest extends TestCase
3535

3636
private $tmpDir;
3737

38-
public function setUp()
38+
protected function setUp()
3939
{
4040
$this->templateFinder = $this
4141
->getMockBuilder(TemplateFinderInterface::class)
@@ -56,7 +56,7 @@ public function setUp()
5656
$this->filesystem->mkdir($this->tmpDir);
5757
}
5858

59-
public function tearDown()
59+
protected function tearDown()
6060
{
6161
$this->filesystem->remove($this->tmpDir);
6262
}

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Annotations\Annotation;
1515
use Symfony\Bundle\FullStack;
1616
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
1718
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1819
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1920
use Symfony\Component\Cache\Adapter\ChainAdapter;
@@ -871,6 +872,7 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile
871872
$container->getCompilerPassConfig()->setOptimizationPasses(array());
872873
$container->getCompilerPassConfig()->setRemovingPasses(array());
873874
}
875+
$container->getCompilerPassConfig()->setBeforeRemovingPasses(array(new AddAnnotationsCachedReaderPass()));
874876
$container->compile();
875877

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

0 commit comments

Comments
 (0)