Skip to content
Permalink
Browse files

bug #31991 [EventDispatcher] collect called listeners information onl…

…y once (xabbuh)

This PR was merged into the 4.3 branch.

Discussion
----------

[EventDispatcher] collect called listeners information only once

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31970
| License       | MIT
| Doc PR        |

Commits
-------

284262a collect called listeners information only once
  • Loading branch information...
fabpot committed Jun 11, 2019
2 parents bde8204 + 284262a commit ac1a660130fd0e5fc51ebbae811417ae5b695631
Showing with 13 additions and 13 deletions.
  1. +13 −13 src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
@@ -224,22 +224,22 @@ public function getNotCalledListeners(/* Request $request = null */)
}
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
$calledListeners = [];
if (null !== $this->callStack) {
foreach ($this->callStack as $calledListener) {
list(, $requestHash) = $this->callStack->getInfo();
if (null === $hash || $hash === $requestHash) {
$calledListeners[] = $calledListener->getWrappedListener();
}
}
}
$notCalled = [];
foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) {
$called = false;
if (null !== $this->callStack) {
foreach ($this->callStack as $calledListener) {
list(, $requestHash) = $this->callStack->getInfo();
if ((null === $hash || $hash === $requestHash) && $calledListener->getWrappedListener() === $listener) {
$called = true;
break;
}
}
}
if (!$called) {
if (!\in_array($listener, $calledListeners, true)) {
if (!$listener instanceof WrappedListener) {
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
}

0 comments on commit ac1a660

Please sign in to comment.
You can’t perform that action at this time.