Skip to content

Commit bbef1d1

Browse files
committed
Symfony\Component\EventDispatcher: wrap calling the handlers into a try-catch block
1 parent 165f14d commit bbef1d1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

symfony/event-dispatcher/EventDispatcher.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\EventDispatcher;
1313

14+
use Throwable;
15+
use Exception;
16+
1417
use Psr\EventDispatcher\StoppableEventInterface;
1518
use Symfony\Component\EventDispatcher\Debug\WrappedListener;
1619

@@ -217,7 +220,17 @@ protected function callListeners(iterable $listeners, string $eventName, object
217220
if ($stoppable && $event->isPropagationStopped()) {
218221
break;
219222
}
220-
$listener($event, $eventName, $this);
223+
try {
224+
$listener($event, $eventName, $this);
225+
} catch (Throwable $t) {
226+
// it is just not acceptable in such a heterogeneous infra
227+
// structure like NC that one badly designed listener stops all
228+
// others.
229+
\OCP\Server::get(\Psr\Log\LoggerInterface::class)->error(
230+
'Exception during event dispatch',
231+
[ 'exception' => new \Exception('Exception during event dispatch', 0, $t) ],
232+
);
233+
}
221234
}
222235
}
223236

0 commit comments

Comments
 (0)