10000 Added debug argument to decide if debug page should be shown or not · symfony/symfony@c749df4 · GitHub
[go: up one dir, main page]

Skip to content

Commit c749df4

Browse files
committed
Added debug argument to decide if debug page should be shown or not
1 parent 2fd34ce commit c749df4

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Symfony/Component/ErrorHandler/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
}

src/Symfony/Component/ErrorHandler/ErrorHandler.php

Lines changed: 6 additions & 3 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;
@@ -107,7 +108,7 @@ class ErrorHandler
107108
/**
108109
* Registers the error handler.
109110
*/
110-
public static function register(self $handler = null, bool $replace = true): self
111+
public static function register(self $handler = null, bool $replace = true, bool $debug = false): self
111112
{
112113
if (null === self::$reservedMemory) {
113114
self::$reservedMemory = str_repeat('x', 10240);
@@ -116,6 +117,7 @@ public static function register(self $handler = null, bool $replace = true): sel
116117

117118
if ($handlerIsNew = null === $handler) {
118119
$handler = new static();
120+
$handler->debug = $debug;
119121
}
120122

121123
if (null === $prev = set_error_handler([$handler, 'handleError'])) {
@@ -180,14 +182,15 @@ public static function call(callable $function, ...$arguments)
180182
}
181183
}
182184

183-
public function __construct(BufferingLogger $bootstrappingLogger = null)
185+
public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false)
184186
{
185187
if ($bootstrappingLogger) {
186188
$this->bootstrappingLogger = $bootstrappingLogger;
187189
$this->setDefaultLogger($bootstrappingLogger);
188190
}
189191
$this->traceReflector = new \ReflectionProperty('Exception', 'trace');
190192
$this->traceReflector->setAccessible(true);
193+
$this->debug = $debug;
191194
}
192195

193196
/**
@@ -697,7 +700,7 @@ public static function handleFatalError(array $error = null): void
697700
*/
698701
private function renderException(\Throwable $exception): void
699702
{
700-
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer(0 !== $this->scopedErrors);
703+
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
701704

702705
$exception = $renderer->render($exception);
703706

0 commit comments

Comments
 (0)
0