Skip to content

Commit 799bc2a

Browse files
bug #39944 [HttpKernel] Configure the ErrorHandler even when it is overriden (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Configure the ErrorHandler even when it is overriden | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Fixes the part of getsentry/sentry-symfony#421 that is about `DebugHandlersListener`. Commits ------- 31817b4 [HttpKernel] Configure the ErrorHandler even when it is overriden
2 parents bf1752a + 31817b4 commit 799bc2a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*/
3434
class DebugHandlersListener implements EventSubscriberInterface
3535
{
36+
private $earlyHandler;
3637
private $exceptionHandler;
3738
private $logger;
3839
private $levels;
@@ -53,6 +54,10 @@ class DebugHandlersListener implements EventSubscriberInterface
5354
*/
5455
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true)
5556
{
57+
$handler = set_exception_handler('var_dump');
58+
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
59+
restore_exception_handler();
60+
5661
$this->exceptionHandler = $exceptionHandler;
5762
$this->logger = $logger;
5863
$this->levels = null === $levels ? \E_ALL : $levels;
@@ -79,6 +84,10 @@ public function configure(Event $event = null)
7984
$handler = \is_array($handler) ? $handler[0] : null;
8085
restore_exception_handler();
8186

87+
if (!$handler instanceof ErrorHandler && !$handler instanceof LegacyErrorHandler) {
88+
$handler = $this->earlyHandler;
89+
}
90+
8291
if ($this->logger || null !== $this->throwAt) {
8392
if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) {
8493
if ($this->logger) {

0 commit comments

Comments
 (0)