From b6a591c720046f36688e4be4ed8d41853a01abe3 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 6 Mar 2015 20:09:59 +0300 Subject: [PATCH] Fixes #7571: HTTP status 500 and "An internal server error occurred." are now returned in case there was an exception in layout and `YII_DEBUG` is false --- framework/CHANGELOG.md | 1 + framework/base/ErrorHandler.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index a2e5ce6..0125a10 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -8,6 +8,7 @@ Yii Framework 2 Change Log - Bug #7603: Fixed escape characters in `FormatConverter` to work with unicode characters (maddoger, cebe) - Enh #7488: Added `StringHelper::explode` to perform explode with trimming and skipping of empty elements (SilverFire, nineinchnick, creocoder, samdark) - Enh #7562: `yii help` now lists all sub-commands by default (callmez) +- Enh #7571: HTTP status 500 and "An internal server error occurred." are now returned in case there was an exception in layout and `YII_DEBUG` is false (samdark) - Enh: Added `yii\helper\Console::wrapText()` method to wrap indented text by console window width and used it in `yii help` command (cebe) - Chg: Updated dependency to `cebe/markdown` to version `1.1.x` (cebe) diff --git a/framework/base/ErrorHandler.php b/framework/base/ErrorHandler.php index 2de8ecc..13cb452 100644 --- a/framework/base/ErrorHandler.php +++ b/framework/base/ErrorHandler.php @@ -107,9 +107,15 @@ abstract class ErrorHandler extends Component } else { echo '
' . htmlspecialchars($msg, ENT_QUOTES, Yii::$app->charset) . '
'; } + } else { + echo 'An internal server error occurred.'; } $msg .= "\n\$_SERVER = " . VarDumper::export($_SERVER); error_log($msg); + + if (PHP_SAPI !== 'cli') { + http_response_code(500); + } exit(1); }