[HttpKernel] ensured that the Request is null when outside of the Request scope
This commit is contained in:
parent
2ffcfb98c8
commit
0892135f45
@ -56,11 +56,13 @@ class ContainerAwareHttpKernel extends HttpKernel
|
||||
try {
|
||||
$response = parent::handle($request, $type, $catch);
|
||||
} catch (\Exception $e) {
|
||||
$this->container->set('request', null, 'request');
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->container->set('request', null, 'request');
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
return $response;
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests;
|
||||
namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel;
|
||||
@ -54,10 +54,15 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
->with($this->equalTo('request'))
|
||||
;
|
||||
$container
|
||||
->expects($this->once())
|
||||
->expects($this->at(1))
|
||||
->method('set')
|
||||
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
|
||||
;
|
||||
$container
|
||||
->expects($this->at(2))
|
||||
->method('set')
|
||||
->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request'))
|
||||
;
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
@ -101,10 +106,15 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
->with($this->equalTo('request'))
|
||||
;
|
||||
$container
|
||||
->expects($this->once())
|
||||
->expects($this->at(1))
|
||||
->method('set')
|
||||
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
|
||||
;
|
||||
$container
|
||||
->expects($this->at(2))
|
||||
->method('set')
|
||||
->with($this->equalTo('request'), $this->equalTo(null), $this->equalTo('request'))
|
||||
;
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
|
Reference in New Issue
Block a user