当我访问 wordpress dashbord 安装新插件时,会出现如上所述的错误
stdClass::$plugin 在 /var/sentora/hostdata/websitenligne/public_html/sme2/wp-includes/class-wp-list-util.php 第 150 行
public function pluck( $field, $index_key = null ) {
if ( ! $index_key ) {
/*
* This is simple. Could at some point wrap array_column()
* if we knew we had an array of arrays.
*/
foreach ( $this->output as $key => $value ) {
if ( is_object( $value ) ) {
$this->output[ $key ] = $value->$field;
} else {
$this->output[ $key ] = $value[ $field ];
}
}
return $this->output;
}
/*
* When index_key is not set for a particular item, push the value
* to the end of the stack. This is how array_column() behaves.
*/
$newlist = array();
foreach ( $this->output as $value ) {
if ( is_object( $value ) ) {
if ( isset( $value->$index_key ) ) {
$newlist[ $value->$index_key ] = $value->$field;
} else {
$newlist[] = $value->$field;
}
} else {
if ( isset( $value[ $index_key ] ) ) {
$newlist[ $value[ $index_key ] ] = $value[ $field ];
} else {
$newlist[] = $value[ $field ];
}
}
}
$this->output = $newlist;
return $this->output;
}Run Code Online (Sandbox Code Playgroud)
错误是什么?
此问题似乎是在 4.7 版中首次引入的,是由于wp-includes/class-wp-list-util.php未检查对象属性是否已设置所致。
看起来它仍然存在于 WordPress 5.2.1 中(本文发布时最新版本)。第 152 行应该类似于:
$this->output[ $key ] = isset( $value->$field ) ? $value->$field : null;
Run Code Online (Sandbox Code Playgroud)
无论如何...要删除此警告,请编辑wp-config.php并更改此内容:
define( 'WP_DEBUG', true );
Run Code Online (Sandbox Code Playgroud)
...对此(或WP_DEBUG完全注释掉该行):
define( 'WP_DEBUG', false );
Run Code Online (Sandbox Code Playgroud)
或者,如果您想启用WP_DEBUG但将其输出限制为wp-content/debug.log,您可以添加以下内容:
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15142 次 |
| 最近记录: |