Skip to content

Commit

Permalink
bug #33674 [ErrorHandler] Show fallback error page when default error…
Browse files Browse the repository at this point in the history
… controller is disabled (yceruto)

This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] Show fallback error page when default error controller is disabled

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This would avoid a blank page on errors when we've disabled the default error controller. e.g:
```yaml
framework:
    error_controller: null
```
So, we will show you the default HTML error page.

Commits
-------

8eea11c Show fallback error page when framework.error_controller is null
  • Loading branch information
fabpot committed Sep 25, 2019
2 parents 745248f + 8eea11c commit b180208
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/ErrorHandler/ErrorHandler.php
Expand Up @@ -603,7 +603,7 @@ public function handleException($exception, array $error = null)
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {
}
if ($exception === $handlerException) {
if ($exception === $handlerException && null === $this->exceptionHandler) {
self::$reservedMemory = null; // Disable the fatal error handler
throw $exception; // Give back $exception to the native handler
}
Expand Down Expand Up @@ -706,7 +706,7 @@ private function sendPhpResponse(\Throwable $exception)
$exception = FlattenException::createFromThrowable($exception);
$statusCode = $exception->getStatusCode();
$headers = $exception->getHeaders();
$response = (new HtmlErrorRenderer(true))->render($exception);
$response = (new HtmlErrorRenderer(0 !== $this->scopedErrors))->render($exception);
} else {
$message = htmlspecialchars($exception->getMessage(), ENT_COMPAT | ENT_SUBSTITUTE, $charset);
$response = sprintf('<!DOCTYPE html><html><head><meta charset="%s" /><meta name="robots" content="noindex,nofollow" /></head><body>%s</body></html>', $charset, $message);
Expand Down

0 comments on commit b180208

Please sign in to comment.