diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-09-08 15:07:37 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-09-08 15:18:27 +0200 |
commit | 33c1216ff6b2a362bd6b3c073c72b16110766efe (patch) | |
tree | 59868e7b48d9dfff3de2209bca07b3153fe9e7a2 /Http/Firewall.php | |
parent | e3b1e223c042122945644e34fdae102e843d50dd (diff) | |
download | symfony-security-33c1216ff6b2a362bd6b3c073c72b16110766efe.zip symfony-security-33c1216ff6b2a362bd6b3c073c72b16110766efe.tar.gz symfony-security-33c1216ff6b2a362bd6b3c073c72b16110766efe.tar.bz2 |
[Security] made sure that the exception listener is always removed from the event dispatcher at the end of the request
Diffstat (limited to 'Http/Firewall.php')
-rw-r--r-- | Http/Firewall.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Http/Firewall.php b/Http/Firewall.php index 36df81a..5a1e9d5 100644 --- a/Http/Firewall.php +++ b/Http/Firewall.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Security\Http; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -30,6 +31,7 @@ class Firewall implements EventSubscriberInterface { private $map; private $dispatcher; + private $exceptionListeners; /** * Constructor. @@ -41,6 +43,7 @@ class Firewall implements EventSubscriberInterface { $this->map = $map; $this->dispatcher = $dispatcher; + $this->exceptionListeners = new \SplObjectStorage(); } /** @@ -57,6 +60,7 @@ class Firewall implements EventSubscriberInterface // register listeners for this firewall list($listeners, $exception) = $this->map->getListeners($event->getRequest()); if (null !== $exception) { + $this->exceptionListeners[$event->getRequest()] = $exception; $exception->register($this->dispatcher); } @@ -70,8 +74,21 @@ class Firewall implements EventSubscriberInterface } } + public function onKernelFinishRequest(FinishRequestEvent $event) + { + $request = $event->getRequest(); + + if (isset($this->exceptionListeners[$request])) { + $this->exceptionListeners[$request]->unregister($this->dispatcher); + unset($this->exceptionListeners[$request]); + } + } + public static function getSubscribedEvents() { - return array(KernelEvents::REQUEST => array('onKernelRequest', 8)); + return array( + KernelEvents::REQUEST => array('onKernelRequest', 8), + KernelEvents::FINISH_REQUEST => 'onKernelFinishRequest', + ); } } |