Skip to content

Commit d272149

Browse files
bug #35464 [ErrorHandler] Add debug argument to decide whether debug page is shown or not (yceruto)
This PR was merged into the 4.4 branch. Discussion ---------- [ErrorHandler] Add debug argument to decide whether debug page is shown or not | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35448 | License | MIT | Doc PR | - This ensures that the debug page (with stack trace) won't be (by default) displayed in non-CLI context when an early error occurs (after FB::boot()) in non-debug mode (prod). And `Debug::enable()` will enable it explicitly. Commits ------- cf80224589 Added debug argument to decide if debug page should be shown or not
2 parents ce4d1e4 + 3a36925 commit d272149

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static function enable(): ErrorHandler
3131

3232
DebugClassLoader::enable();
3333

34-
return ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
34+
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
3535
}
3636
}

ErrorHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class ErrorHandler
9292
private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
9393
private $loggedErrors = 0;
9494
private $traceReflector;
95+
private $debug;
9596

9697
private $isRecursive = 0;
9798
private $isRoot = false;
@@ -180,14 +181,15 @@ public static function call(callable $function, ...$arguments)
180181
}
181182
}
182183

183-
public function __construct(BufferingLogger $bootstrappingLogger = null)
184+
public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false)
184185
{
185186
if ($bootstrappingLogger) {
186187
$this->bootstrappingLogger = $bootstrappingLogger;
187188
$this->setDefaultLogger($bootstrappingLogger);
188189
}
189190
$this->traceReflector = new \ReflectionProperty('Exception', 'trace');
190191
$this->traceReflector->setAccessible(true);
192+
$this->debug = $debug;
191193
}
192194

193195
/**
@@ -697,7 +699,7 @@ public static function handleFatalError(array $error = null): void
697699
*/
698700
private function renderException(\Throwable $exception): void
699701
{
700-
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer(0 !== $this->scopedErrors);
702+
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
701703

702704
$exception = $renderer->render($exception);
703705

0 commit comments

Comments
 (0)