I have searched & tried various solutions to this problem, none of them work.
It looks like WordPress ignores the following and logs Deprecated messages anyway:
error_reporting(E_ALL ^ E_DEPRECATED);
ini_set('error_reporting', E_ALL ^ E_DEPRECATED);
My php.ini:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
My wp-config.php:
<?php
define( 'WP_CACHE', true );
error_reporting(E_ALL ^ E_DEPRECATED);
...
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Plugins are spamming my debug.log file with PHP Deprecated: ... log messages. Several GB generated each day. Makes debug.log unusable.
I report to Plugin developers, but some do not fix in timely manner. I cannot fix myself, as Plugin update overwrite my changes.
What is the solution to disable these?
Server:
UPDATE
I've created a WordPress plugin to add, remove and control the MU plugin from the comfort of your admin panel.
Original post
No matter what you set for error_reporting() inside the wp-config.php and no matter what's in the php.ini, it will be overwritten by WordPress in function wp_debug_mode() (in wp-includes/load.php called by wp-settings.php) as follows:
if ( WP_DEBUG ) {
error_reporting( E_ALL );
//...
} else {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
}
You could, of course, change E_ALL to E_ALL ^ E_DEPRECATED inside wp-includes/load.php, but that is (eventually) going to be overwritten with WordPress updates.
Another (persistent) option is to use a must use plugin to reset error_reporting (again). This however will not mute deprecation warnings resulting from the WordPress core. To do that anyway, create the directory wp-content/mu-plugins if it doesn't exist. Inside that directory add __error_reporting.php with the following contents:
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
Must use plugins will be loaded in alphabetical order before all other plugins (hence the __ prefix).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With