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"
This commit is contained in:
kenjis 2023-10-25 07:00:00 +09:00
parent 407c108fd9
commit 1874e62fd1
No known key found for this signature in database
GPG Key ID: BD254878922AF198
4 changed files with 18 additions and 2 deletions

View File

@ -7,6 +7,8 @@
| In development, we want to show as many errors as possible to help
| make sure they don't make it to production. And save us hours of
| painful debugging.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
error_reporting(-1);
ini_set('display_errors', '1');

View File

@ -6,6 +6,8 @@
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
|
| If you set 'display_errors' to '1', CI4's detailed error report will show.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

View File

@ -129,7 +129,13 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
// Production environments should have a custom exception file.
$view = 'production.php';
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
if (
str_ireplace(
['off', 'none', 'no', 'false', 'null', '0'],
'',
ini_get('display_errors')
) !== ''
) {
$view = 'error_exception.php';
}

View File

@ -253,7 +253,13 @@ class Exceptions
$view = 'production.php';
$templatePath = rtrim($templatePath, '\\/ ') . DIRECTORY_SEPARATOR;
if (str_ireplace(['off', 'none', 'no', 'false', 'null'], '', ini_get('display_errors')) !== '') {
if (
str_ireplace(
['off', 'none', 'no', 'false', 'null', '0'],
'',
ini_get('display_errors')
) !== ''
) {
$view = 'error_exception.php';
}