Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent calls to error_reporting() and/or ini_set('display_errors', 'On') from overriding php.ini settings

I had this setting in my php.ini file:

error_reporting = E_ERROR|E_PARSE|E_CORE_ERROR|E_COMPILE_ERROR

But I was still receiving thousands of NOTICE and WARNING entries in the error log every minute. I of course realize I would better deal with those errors, but this is not my code and I am not being paid to do that, I just needed to get rid of those fat error_log files (Gbs per day).

I searched through the code and removed all error_reporting() calls, and that did the trick but, is there a way to disallow error_reporting() from overriding php.ini settings?

Could I also prevent calls to ini_set('display_errors') from overriding php.ini settings?

like image 388
AJJ Avatar asked Dec 11 '25 18:12

AJJ


1 Answers

is there a way to disallow error_reporting() from overriding php.ini settings?

Maybe.

If you're using mod_php under Apache (or FastCGI via FPM), you can use php_admin_value and php_admin_flag to force certain INI settings in such a way that ini_set will be unable to override.

Unfortunately I don't know of a way to neuter error_reporting other than disable_functions -- but this will throw a PHP Warning every time it's used.

(As a side note, I find it curious that a developer would set an error reporting level in production and still be producing such a high volume of logs.)

like image 55
Charles Avatar answered Dec 14 '25 10:12

Charles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!