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

Skip to content

Commit a8718a8

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

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function boot()
7070
{
7171
ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true);
7272

73+
throw new \LogicException('Foo');
74+
7375
if ($this->container->getParameter('kernel.http_method_override')) {
7476
Request::enableHttpMethodParameterOverride();
7577
}

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, 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);
@@ -150,6 +151,7 @@ public static function register(self $handler = null, bool $replace = true): sel
150151
}
151152

152153
$handler->throwAt(E_ALL & $handler->thrownErrors, true);
154+
$handler->debug = $debug;
153155

154156
return $handler;
155157
}
@@ -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;
18718 AE18 9
$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