minor #28224 [Security\Http] Restore laziness of listener iterator (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Security\Http] Restore laziness of listener iterator | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no (never released) | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Alternative to #28223 Restores laziness that I broke in merge commit2dedacbc04 (diff-31ca8a8ce837591218082b00363149fc)
Commits -------2ebc75b
[Security\Http] Restore laziness of listener iterator
This commit is contained in:
commit
2c863c6545
|
@ -50,31 +50,38 @@ class Firewall implements EventSubscriberInterface
|
||||||
// register listeners for this firewall
|
// register listeners for this firewall
|
||||||
$listeners = $this->map->getListeners($event->getRequest());
|
$listeners = $this->map->getListeners($event->getRequest());
|
||||||
|
|
||||||
$accessListener = null;
|
$authenticationListeners = $listeners[0];
|
||||||
$authenticationListeners = array();
|
$exceptionListener = $listeners[1];
|
||||||
|
$logoutListener = isset($listeners[2]) ? $listeners[2] : null;
|
||||||
|
|
||||||
foreach ($listeners[0] as $listener) {
|
if (null !== $exceptionListener) {
|
||||||
if ($listener instanceof AccessListener) {
|
|
||||||
$accessListener = $listener;
|
|
||||||
} else {
|
|
||||||
$authenticationListeners[] = $listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $exceptionListener = $listeners[1]) {
|
|
||||||
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
|
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
|
||||||
$exceptionListener->register($this->dispatcher);
|
$exceptionListener->register($this->dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $logoutListener = isset($listeners[2]) ? $listeners[2] : null) {
|
$authenticationListeners = function () use ($authenticationListeners, $logoutListener) {
|
||||||
$authenticationListeners[] = $logoutListener;
|
$accessListener = null;
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $accessListener) {
|
foreach ($authenticationListeners as $listener) {
|
||||||
$authenticationListeners[] = $accessListener;
|
if ($listener instanceof AccessListener) {
|
||||||
}
|
$accessListener = $listener;
|
||||||
|
|
||||||
$this->handleRequest($event, $authenticationListeners);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield $listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $logoutListener) {
|
||||||
|
yield $logoutListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $accessListener) {
|
||||||
|
yield $accessListener;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->handleRequest($event, $authenticationListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelFinishRequest(FinishRequestEvent $event)
|
public function onKernelFinishRequest(FinishRequestEvent $event)
|
||||||
|
|
Reference in New Issue