Skip to content

Commit c511e46

Browse files
committed
bug #32164 [EventDispatcher] collect called listeners information only once (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [EventDispatcher] collect called listeners information only once | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 2ad32df collect called listeners information only once
2 parents 7cc4cab + 2ad32df commit c511e46

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,18 @@ public function getNotCalledListeners()
191191
return [];
192192
}
193193

194+
$calledListeners = [];
195+
196+
if (null !== $this->callStack) {
197+
foreach ($this->callStack as $calledListener) {
198+
$calledListeners[] = $calledListener->getWrappedListener();
199+
}
200+
}
201+
194202
$notCalled = [];
195203
foreach ($allListeners as $eventName => $listeners) {
196204
foreach ($listeners as $listener) {
197-
$called = false;
198-
if (null !== $this->callStack) {
199-
foreach ($this->callStack as $calledListener) {
200-
if ($calledListener->getWrappedListener() === $listener) {
201-
$called = true;
202-
203-
break;
204-
}
205-
}
206-
}
207-
208-
if (!$called) {
205+
if (!\in_array($listener, $calledListeners, true)) {
209206
if (!$listener instanceof WrappedListener) {
210207
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
211208
}

0 commit comments

Comments
 (0)