From 853f681957c33c8f87db6d876f05c94455ae014a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 9 May 2013 09:53:36 +0200 Subject: [PATCH] fixed request scope issues (refs #7457) --- src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php | 5 +++++ .../DependencyInjection/ContainerAwareHttpKernel.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 085ad876df1e..8a04ed90148c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -28,6 +28,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass; @@ -54,6 +55,10 @@ public function build(ContainerBuilder $container) { parent::build($container); + // we need to add the request scope as early as possible so that + // the compilation can find scope widening issues + $container->addScope(new Scope('request')); + $container->addCompilerPass(new RoutingResolverPass()); $container->addCompilerPass(new ProfilerPass()); $container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_AFTER_REMOVING); diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php index da917fd32b9a..18ca8ef2f7bf 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -42,7 +42,11 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter parent::__construct($dispatcher, $controllerResolver); $this->container = $container; - $container->addScope(new Scope('request')); + + // the request scope might have been created before (see FrameworkBundle) + if (!$container->hasScope('request')) { + $container->addScope(new Scope('request')); + } } /**