[英]Getting Warning in wordpress plugin post-my-contact-form-7 after updating to the PHP 7.2.0
I am Working on a wordpress project it's working fine 我正在一个wordpress项目上工作正常
When i Update the PHP version 7.2.0 I am getting warning like this: 当我更新PHP版本7.2.0时,我得到这样的警告:
Warning: Use of undefined constant WP_GURUS_DEBUG - assumed 'WP_GURUS_DEBUG' (this will throw an Error in a future version of PHP) in C:\\wamp\\www\\wordpress1\\wp-content\\plugins\\post-my-contact-form-7\\includes\\wordpress-gurus-debug-api.php on line 9
警告:在C:\\ wamp \\ www \\ wordpress1 \\ wp-content \\ plugins \\ post-my-contact-form-7中使用未定义的常量WP_GURUS_DEBUG-假定为'WP_GURUS_DEBUG'(这将在以后的PHP版本中引发错误)第9行的\\ includes \\ wordpress-gurus-debug-api.php
My wordpress version is 4.9.1 我的WordPress版本是4.9.1
My plugin: 我的插件:
Post My CF7 Form Version 3.2.0
发布我的CF7表单版本3.2.0
Here is the plugin file: 这是插件文件:
<?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);
}
}
}
} ?>
How to resolve this warning? 如何解决此警告?
EDIT: I informed the plugin maintainer, and this issue should now be resolved simply by updating the plugin. 编辑:我通知了插件维护者,现在只需更新插件即可解决此问题。
Aurovrata Venet wrote:
Aurovrata Venet写道:
oops, my bad!
糟糕,我不好! Fixed in v3.2.1
在v3.2.1中已修复
Post Link: https://wordpress.org/support/topic/warning-use-of-undefined-constant-wp_gurus_debug/#post-9777594
帖子链接: https : //wordpress.org/support/topic/warning-use-of-undefined-constant-wp_gurus_debug/#post-9777594
WP_DEBUG
is already defined (as false
, by default), but WP_GURUS_DEBUG
apparently isn't defined by the plugin by default. WP_DEBUG
已经被定义 (默认情况下为false
),但是WP_GURUS_DEBUG
显然不是默认情况下由插件定义的。 Attempting to use an undefined constant will be considered an error in future versions of PHP, but as a heads-up they are displaying it as a warning to give developers a chance to update their code. 在将来的PHP版本中,尝试使用未定义的常量将被视为错误,但要注意,它们正在将其显示为警告,以使开发人员有机会更新其代码。
The plugin maintainers need to update line 插件维护人员需要更新行
if (true === WP_DEBUG || true === WP_GURUS_DEBUG) {
to check if the constants are defined with something like: 检查常量是否定义为:
if ( ( defined( 'WP_DEBUG' ) AND true === WP_DEBUG ) || ( defined( 'WP_GURUS_DEBUG' ) AND true === WP_GURUS_DEBUG ) ) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.