Skip to content

Commit 4bf7615

Browse files
committed
Merge branch '4.0'
* 4.0: (30 commits) [FrameworkBundle] fix tests [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR [HttpKernel] Fix session handling: decouple "save" from setting response "private" swap filter/function and package names [HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler [HttpKernel] Fix compile error when a legacy container is fresh again Add tests for the HttpKernel request collector and redirection via cookies Uses cookies to track the requests redirection Tweaked some styles in the profiler tables Add type string to docblock for Process::setInput() [Security] Fail gracefully if the security token cannot be unserialized from the session [Form] AbstractLayoutTest - fix DOMDocument casing Run simple-phpunit with --no-suggest option [FrameworkBundle] Fix using "annotations.cached_reader" in after-removing passes bumped Symfony version to 4.0.4 updated VERSION for 4.0.3 updated CHANGELOG for 4.0.3 bumped Symfony version to 3.4.4 updated VERSION for 3.4.3 updated CHANGELOG for 3.4.3 ...
2 parents 8b3d553 + 3f1c2f6 commit 4bf7615

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Reference;
1716

1817
/**
1918
* @internal
@@ -29,14 +28,14 @@ public function process(ContainerBuilder $container)
2928
// "annotation_reader" at build time don't get any cache
3029
if ($container->hasDefinition('annotations.cached_reader')) {
3130
$reader = $container->getDefinition('annotations.cached_reader');
32-
$tags = $reader->getTags();
31+
$properties = $reader->getProperties();
3332

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-
}
33+
if (isset($properties['cacheProviderBackup'])) {
34+
$provider = $properties['cacheProviderBackup']->getValues()[0];
35+
unset($properties['cacheProviderBackup']);
36+
$reader->setProperties($properties);
3837
$container->set('annotations.cached_reader', null);
39-
$container->setDefinition('annotations.cached_reader', $reader->replaceArgument(1, new Reference($provider)));
38+
$container->setDefinition('annotations.cached_reader', $reader->replaceArgument(1, $provider));
4039
}
4140
}
4241
}

DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\Console\Application;
2929
use Symfony\Component\Console\Command\Command;
3030
use Symfony\Component\DependencyInjection\Alias;
31+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
3132
use Symfony\Component\DependencyInjection\ChildDefinition;
3233
use Symfony\Component\DependencyInjection\ContainerBuilder;
3334
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -1128,7 +1129,8 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
11281129
$container
11291130
->getDefinition('annotations.cached_reader')
11301131
->replaceArgument(2, $config['debug'])
1131-
->addTag('annotations.cached_reader', array('provider' => $cacheService))
1132+
// temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1133+
->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
11321134
;
11331135
$container->setAlias('annotation_reader', 'annotations.cached_reader')->setPrivate(true);
11341136
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));

FrameworkBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function build(ContainerBuilder $container)
9494
$container->addCompilerPass((new RegisterListenersPass())->setHotPathEvents($hotPathEvents), PassConfig::TYPE_BEFORE_REMOVING);
9595
$container->addCompilerPass(new TemplatingPass());
9696
$this->addCompilerPassIfExists($container, AddConstraintValidatorsPass::class, PassConfig::TYPE_BEFORE_REMOVING);
97-
$container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
97+
$container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_AFTER_REMOVING, -255);
9898
$this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class);
9999
$this->addCompilerPassIfExists($container, AddConsoleCommandPass::class);
100100
$this->addCompilerPassIfExists($container, TranslatorPass::class);

Tests/Functional/Bundle/TestBundle/DependencyInjection/AnnotationReaderPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class AnnotationReaderPass implements CompilerPassInterface
1919
public function process(ContainerBuilder $container)
2020
{
2121
// simulate using "annotation_reader" in a compiler pass
22-
$container->get('annotation_reader');
22+
$container->get('test.annotation_reader');
2323
}
2424
}

Tests/Functional/Bundle/TestBundle/DependencyInjection/TestExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
1313

14+
use Symfony\Component\DependencyInjection\Alias;
1415
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Extension\Extension;
1617
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
@@ -26,6 +27,8 @@ public function load(array $configs, ContainerBuilder $container)
2627
{
2728
$configuration = $this->getConfiguration($configs, $container);
2829
$config = $this->processConfiguration($configuration, $configs);
30+
31+
$container->setAlias('test.annotation_reader', new Alias('annotation_reader', true));
2932
}
3033

3134
/**

Tests/Functional/Bundle/TestBundle/TestBundle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle;
1313

1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass;
1718
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig;
@@ -27,6 +28,6 @@ public function build(ContainerBuilder $container)
2728

2829
$extension->setCustomConfig(new CustomConfig());
2930

30-
$container->addCompilerPass(new AnnotationReaderPass());
31+
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
3132
}
3233
}

0 commit comments

Comments
 (0)