我正在研究wordpress项目它工作正常
当我更新PHP版本7.2.0时,我收到这样的警告:
警告:使用未定义的常量WP_GURUS_DEBUG - 在C:\ wamp\www\wordpress1\wp-content\plugins\post-my-contact-form-7中假定为'WP_GURUS_DEBUG'(这将在未来版本的PHP中引发错误)第9行包含\ wordpress-gurus-debug-api.php
我的wordpress版本是4.9.1
我的插件:
发表我的CF7表格 版本3.2.0
这是插件文件:
<?php
/**
* Error logging and notices
* @since 1.0.0
* @var string $message to log if in debug mode
*/
if( !function_exists('debug_msg') ){
if (true === WP_DEBUG || true === WP_GURUS_DEBUG) {
$debug_msg_last_line='';
$debug_msg_last_file='';
}
function debug_msg($message,$prefix='') {
if (true === WP_DEBUG || true === WP_GURUS_DEBUG) {
global $debug_msg_last_line,$debug_msg_last_file;
$backtrace = debug_backtrace();
$file = $backtrace[0]['file'];
$files = explode('/',$file);
$dirs = explode('/',plugin_dir_path( __FILE__ ));
$files = array_diff($files,$dirs);
$file = implode('/',$files);
$line = $backtrace[0]['line'];
if($file != $debug_msg_last_file && $line != $debug_msg_last_line){
error_log("DEBUG_MSG: [".$line."]./".$file);
$debug_msg_last_file=$file;
$debug_msg_last_line=$line;
}else{
//error_log("CF7_2_POST: ");
}
if (is_array($message) || is_object($message)) {
error_log(" + ".$prefix.print_r($message, true));
} else {
error_log(" + ".$prefix.$message);
}
}
}
} ?>
Run Code Online (Sandbox Code Playgroud)
如何解决此警告?
编辑:我告诉插件维护者,现在只需更新插件即可解决此问题.
Aurovrata Venet写道:
哎呀,我的坏!在v3.2.1中修复
帖子链接:https: //wordpress.org/support/topic/warning-use-of-undefined-constant-wp_gurus_debug/#post-9777594
WP_DEBUG已经定义(false默认情况下),但WP_GURUS_DEBUG默认情况下插件显然没有定义.尝试使用未定义的常量将在未来的PHP版本中被视为错误,但作为单挑,他们将其显示为警告,以便为开发人员提供更新其代码的机会.
插件维护者需要更新行
if (true === WP_DEBUG || true === WP_GURUS_DEBUG) {
检查常量是否定义为:
if ( ( defined( 'WP_DEBUG' ) AND true === WP_DEBUG ) || ( defined( 'WP_GURUS_DEBUG' ) AND true === WP_GURUS_DEBUG ) ) {
| 归档时间: |
|
| 查看次数: |
483 次 |
| 最近记录: |