when i'm accessing to wordpress dashbord to install new plugin an error occurs as mentionned
stdClass::$plugin in /var/sentora/hostdata/websitenligne/public_html/sme2/wp-includes/class-wp-list-util.php on line 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;
}
what was the error ?
This issue appears to have been first introduced in version 4.7, and is due to wp-includes/class-wp-list-util.php not checking if an object property is set.
It looks like it is still present in WordPress 5.2.1 (latest at the time of this post). Line 152 should be something like:
$this->output[ $key ] = isset( $value->$field ) ? $value->$field : null;
Anyway... To remove this warning, edit your wp-config.php and change this:
define( 'WP_DEBUG', true );
...to this (or comment out the WP_DEBUG line altogether ):
define( 'WP_DEBUG', false );
Alternatively, if you want to leave WP_DEBUG enabled but limit its output to wp-content/debug.log, you can add this instead:
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
this article gave me some good examples how to fix the problem https://www.thetwopercent.co.uk/wordpress-error-solved-notice-undefined-property-stdclass-plugin/ and the way you can find witch plugin is causing the problem is putting this code on that function to se which plugin is causing the problem. then the result will be: isvalidEmpty:1 with this you can find the plugin that is making the issue.
public function pluck( $field, $index_key = null ) {
$newlist = array();
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 code to ouput the plugin that causing the problem
echo('<div style="margin-left: 251px;">' );
echo('<p>is object</p>' );
echo('<h2 style="margin-left: 400px;">'.(string) $key."</h2>
<br/>" );
echo('<h2 style="margin-left: 251px;"> field:'. $field."</h2>
<br/>" );
echo('<h2 style="margin-left: 251px;">
isvalidEmpty:'.empty($value->$field)."</h2><br/>" );
echo('</div>' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With