简体   繁体   English

使用PHP 5.4禁用WordPress 3.7中的严格标准错误

[英]Disabling Strict Standards Errors in WordPress 3.7 with PHP 5.4

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. 在将计算机更新到OS X 10.9后,我试图通过我的php.ini文件禁用WordPress 3.7中的STRICT错误报告。 I am running PHP Version 5.4.17, the one that ships with Mavericks. 我正在运行PHP版本5.4.17,这是与Mavericks一起提供的版本。

In my wp-config.php file, I have enabled define('WP_DEBUG', true); 在我的wp-config.php文件中,我启用了define('WP_DEBUG', true); which was on a working fine before upgrading my OS and as a result, PHP. 在升级我的操作系统之前工作正常,因此,PHP。

In the php.ini file, I have tried setting error_reporting to: 在php.ini文件中,我尝试将error_reporting设置为:

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:

display_errors = Off

After each change to the file, I am restarting apache and httpd with these two commands: 每次更改文件后,我都会使用以下两个命令重新启动apache和httpd:

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: 我正在编辑的php.ini文件与phpinfo()中指向的文件相同,只是为了确保更改正在进行,我一直在编辑error_prepend_string值:

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. 任何关于如何调试这个的想法将非常感激。

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 ) . 在Wordpress 3.7中,函数wp_debug_mode (在wp-includes/load.php定义,并从wp-setings.php )设置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). 由于wp-settings.php本身是在wp-config.php的末尾加载的,所以你不能从wp-config.php更改此设置(或者更确切地说,你可以,但它将被覆盖)。

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 : 解决方案是创建一个“必须使用的插件”,也就是说位于/wp-content/mu-plugins/文件夹中的.php文件包含:

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

I found that only 我发现只有

error_reporting = off

works, as STRICT errors have become part of ALL as of PHP 5.4 which is annoying. 因为STRICT错误已经成为PHP 5.4的一部分,这很烦人。

If you set WP_DEBUG to 'false' in wp-config.php file. 如果在wp-config.php文件中将WP_DEBUG设置为“false”。 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. 这可能发生在强制显示PHP错误,警告和通知的廉价/共享主机上。 In that case, you can remove this line from your wp-config.php file: 在这种情况下,您可以从wp-config.php文件中删除此行:

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. 在我的情况下它的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM