Disabling Strict Standards Errors in WordPress 3.7 with PHP 5.4

jeremyzilar picture jeremyzilar · Oct 25, 2013 · Viewed 10.4k times · Source

I am trying to disable STRICT Error reporting in WordPress 3.7 via my php.ini file after updating my computer to OS X 10.9. I am running PHP Version 5.4.17, the one that ships with Mavericks.

In my wp-config.php file, I have enabled define('WP_DEBUG', true); which was on a working fine before upgrading my OS and as a result, PHP.

In the php.ini file, I have tried setting error_reporting to:

error_reporting = E_ALL

or

error_reporting = E_ALL & ~E_STRICT

or

error_reporting = E_ALL & ~E_DEPRECATED

even

error_reporting = 0

But the errors still appear.

display_errors is set to Off:

display_errors = Off

After each change to the file, I am restarting apache and httpd with these two commands:

httpd -k restart
apachectl restart

The php.ini file I am editing is the same one being pointed to in phpinfo() AND just to make sure changes are going through, I have been editing the error_prepend_string value:

error_prepend_string = "<span style='color: #ff0000'>ERROR: "

and those changes are coming through in the error.

Any thoughts on how to debug this would be much appreciated.

Answer

adelval picture adelval · Oct 27, 2013

In Wordpress 3.7, the function wp_debug_mode (defined in wp-includes/load.php, and called from wp-setings.php) sets error_reporting( E_ALL ).

Since wp-settings.php is itself loaded at the end of wp-config.php, you cannot change this setting from wp-config.php (or rather, you can, but it will be overridden).

A solution is to create a "Must Use plugin", that is to say a .php file located in the /wp-content/mu-plugins/ folder containing :

<?php
if (WP_DEBUG && WP_DEBUG_DISPLAY) 
{
   ini_set('error_reporting', E_ALL & ~E_STRICT & ~E_DEPRECATED);
}