Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac1a660

Browse filesBrowse files
committed
bug #31991 [EventDispatcher] collect called listeners information only 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
2 parents bde8204 + 284262a commit ac1a660
Copy full SHA for ac1a660

File tree

1 file changed

+13
-13
lines changed
Filter options

1 file changed

+13
-13
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,22 @@ public function getNotCalledListeners(/* Request $request = null */)
224224
}
225225

226226
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
227+
$calledListeners = [];
228+
229+
if (null !== $this->callStack) {
230+
foreach ($this->callStack as $calledListener) {
231+
list(, $requestHash) = $this->callStack->getInfo();
232+
233+
if (null === $hash || $hash === $requestHash) {
234+
$calledListeners[] = $calledListener->getWrappedListener();
235+
}
236+
}
237+
}
238+
227239
$notCalled = [];
228240
foreach ($allListeners as $eventName => $listeners) {
229241
foreach ($listeners as $listener) {
230-
$called = false;
231-
if (null !== $this->callStack) {
232-
foreach ($this->callStack as $calledListener) {
233-
list(, $requestHash) = $this->callStack->getInfo();
234-
if ((null === $hash || $hash === $requestHash) && $calledListener->getWrappedListener() === $listener) {
235-
$called = true;
236-
237-
break;
238-
}
239-
}
240-
}
241-
242-
if (!$called) {
242+
if (!\in_array($listener, $calledListeners, true)) {
243243
if (!$listener instanceof WrappedListener) {
244244
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
245245
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.