merged branch fabpot/firewall-leaks (PR #8946)
This PR was merged into the 2.2 branch. Discussion ---------- [Security] fixed a leak in the ContextListener | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Trying to fix leaks when using the same Kernel to handle several requests in a row without resetting the Container or shutting down the Kernel. Commits -------899f176
[Security] fixed a leak in ExceptionListener2fd8a7a
[Security] fixed a leak in the ContextListener
This commit is contained in:
commit
535cf50c3a
@ -38,6 +38,7 @@ class ContextListener implements ListenerInterface
|
|||||||
private $logger;
|
private $logger;
|
||||||
private $userProviders;
|
private $userProviders;
|
||||||
private $dispatcher;
|
private $dispatcher;
|
||||||
|
private $registered;
|
||||||
|
|
||||||
public function __construct(SecurityContextInterface $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
public function __construct(SecurityContextInterface $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
|
||||||
{
|
{
|
||||||
@ -65,8 +66,9 @@ class ContextListener implements ListenerInterface
|
|||||||
*/
|
*/
|
||||||
public function handle(GetResponseEvent $event)
|
public function handle(GetResponseEvent $event)
|
||||||
{
|
{
|
||||||
if (null !== $this->dispatcher && HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
|
if (!$this->registered && null !== $this->dispatcher && HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
|
||||||
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
|
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
|
||||||
|
$this->registered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
@ -76,6 +76,10 @@ class ExceptionListener
|
|||||||
*/
|
*/
|
||||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||||
{
|
{
|
||||||
|
// we need to remove ourselves as the exception listener can be
|
||||||
|
// different depending on the Request
|
||||||
|
$event->getDispatcher()->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException'));
|
||||||
|
|
||||||
$exception = $event->getException();
|
$exception = $event->getException();
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user