Skip to content

Commit a30e166

Browse files
committed
[EventDispatcher] Try first if the event is Stopped
1 parent 1314365 commit a30e166

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
155155
protected function doDispatch($listeners, $eventName, Event $event)
156156
{
157157
foreach ($listeners as $listener) {
158-
call_user_func($listener, $event);
159158
if ($event->isPropagationStopped()) {
160159
break;
161160
}
161+
call_user_func($listener, $event);
162162
}
163163
}
164164

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public function dispatch($eventName, Event $event = null)
136136
$event = new Event();
137137
}
138138

139+
if (null !== $this->logger && $event->isPropagationStopped()) {
140+
$this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
141+
}
142+
139143
$eventId = ++$this->lastEventId;
140144

141145
$this->preDispatch($eventName, $eventId, $event);

0 commit comments

Comments
 (0)