Skip to content
Permalink
Browse files Browse the repository at this point in the history
Added debug argument to decide if debug page should be shown or not
  • Loading branch information
yceruto committed Jan 26, 2020
1 parent 2fd34ce commit cf80224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/ErrorHandler/Debug.php
Expand Up @@ -31,6 +31,6 @@ public static function enable(): ErrorHandler

DebugClassLoader::enable();

return ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
}
}
6 changes: 4 additions & 2 deletions src/Symfony/Component/ErrorHandler/ErrorHandler.php
Expand Up @@ -92,6 +92,7 @@ class ErrorHandler
private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
private $loggedErrors = 0;
private $traceReflector;
private $debug;

private $isRecursive = 0;
private $isRoot = false;
Expand Down Expand Up @@ -180,14 +181,15 @@ public static function call(callable $function, ...$arguments)
}
}

public function __construct(BufferingLogger $bootstrappingLogger = null)
public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false)
{
if ($bootstrappingLogger) {
$this->bootstrappingLogger = $bootstrappingLogger;
$this->setDefaultLogger($bootstrappingLogger);
}
$this->traceReflector = new \ReflectionProperty('Exception', 'trace');
$this->traceReflector->setAccessible(true);
$this->debug = $debug;
}

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

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

Expand Down

1 comment on commit cf80224

@andreblb
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atualização de segurança

Please sign in to comment.