Skip to content

Commit

Permalink
[HttpKernel] ensured that the Request is null when outside of the Req…
Browse files Browse the repository at this point in the history
…uest scope
  • Loading branch information
fabpot committed Mar 20, 2013
1 parent 2ffcfb9 commit 0892135
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,10 +54,15 @@ public function testHandle($type)
->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');
Expand Down Expand Up @@ -101,10 +106,15 @@ public function testHandleRestoresThePreviousRequestOnException($type)
->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');
Expand Down

0 comments on commit 0892135

Please sign in to comment.