From a30e1662d865cce9212e0f60dd48f825bab87148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Sun, 3 Apr 2016 23:45:45 +0200 Subject: [PATCH] [EventDispatcher] Try first if the event is Stopped --- src/Symfony/Component/EventDispatcher/EventDispatcher.php | 2 +- .../Component/HttpKernel/Debug/TraceableEventDispatcher.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 8ec832e8a9..58535f2416 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -155,10 +155,10 @@ class EventDispatcher implements EventDispatcherInterface protected function doDispatch($listeners, $eventName, Event $event) { foreach ($listeners as $listener) { - call_user_func($listener, $event); if ($event->isPropagationStopped()) { break; } + call_user_func($listener, $event); } } diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index 81e17da627..b387c95006 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -136,6 +136,10 @@ class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEve $event = new Event(); } + if (null !== $this->logger && $event->isPropagationStopped()) { + $this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName)); + } + $eventId = ++$this->lastEventId; $this->preDispatch($eventName, $eventId, $event);