Skip to content

Commit 1874e62

Browse files
committed
fix: detailed error report is displayed in production environment
php > ini_set('display_errors', '0'); php > var_dump(ini_get('display_errors')); string(1) "0" php > ini_set('display_errors', 0); php > var_dump(ini_get('display_errors')); string(1) "0" php > ini_set('display_errors', false); php > var_dump(ini_get('display_errors')); string(0) "" php > ini_set('display_errors', null); php > var_dump(ini_get('display_errors')); string(0) "" php > ini_set('display_errors', 'off'); php > var_dump(ini_get('display_errors')); string(3) "off"
1 parent 407c108 commit 1874e62

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

app/Config/Boot/development.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
| In development, we want to show as many errors as possible to help
88
| make sure they don't make it to production. And save us hours of
99
| painful debugging.
10+
|
11+
| If you set 'display_errors' to '1', CI4's detailed error report will show.
1012
*/
1113
error_reporting(-1);
1214
ini_set('display_errors', '1');

app/Config/Boot/production.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
|--------------------------------------------------------------------------
77
| Don't show ANY in production environments. Instead, let the system catch
88
| it and display a generic error message.
9+
|
10+
| If you set 'display_errors' to '1', CI4's detailed error report will show.
911
*/
1012
ini_set('display_errors', '0');
1113
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

system/Debug/ExceptionHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ protected function determineView(Throwable $exception, string $templatePath): st
129129
// Production environments should have a custom exception file.
130130
$view = 'production.php';
131131

132-
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
132+
if (
133+
str_ireplace(
134+
['off', 'none', 'no', 'false', 'null', '0'],
135+
'',
136+
ini_get('display_errors')
137+
) !== ''
138+
) {
133139
$view = 'error_exception.php';
134140
}
135141

system/Debug/Exceptions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,13 @@ protected function determineView(Throwable $exception, string $templatePath): st
253253
$view = 'production.php';
254254
$templatePath = rtrim($templatePath, '\\/ ') . DIRECTORY_SEPARATOR;
255255

256-
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
256+
if (
257+
str_ireplace(
258+
['off', 'none', 'no', 'false', 'null', '0'],
259+
'',
260+
ini_get('display_errors')
261+
) !== ''
262+
) {
257263
$view = 'error_exception.php';
258264
}
259265

0 commit comments

Comments
 (0)