9
votes

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.

3
Inside the phpinfo() what's the value of error_reporting? - Ja͢ck
phpinfo() will also show the actual local and master runtime values for error_reporting and display_errors in the Core section, please share what they show. - Niels Keurentjes
@Jack The Local Value is '32767'. The Master Value is 'no value'. - jeremyzilar
I think its.. error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT if my memory serves me correctly - xlordt
Also, error_reporting(0); isn't going to work of course in php.ini, that should be error_reporting = 0. But 32767 most certainly includes E_STRICT (2048). Either you're not editing the correct php config file, or your code resets the value somewhere before the phpinfo() call. - Niels Keurentjes

3 Answers

18
votes

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);
}
0
votes

I found that only

error_reporting = off

works, as STRICT errors have become part of ALL as of PHP 5.4 which is annoying.

0
votes

If you set WP_DEBUG to 'false' in wp-config.php file. These do not affect your website.

Bot the problem is that above does not work sometime. That can happen on cheap/shared hostings that force displaying PHP ERRORS, warnings and notices. In that case, you can remove this line from your wp-config.php file:

define('WP_DEBUG', false);

and place this:

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

in my case its working.