2

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 ?

6 Answers 6

7

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 );
  • WP_DEBUG (and especially WP_DEBUG_LOG should not be enabled in a production environment, or on any publicly-accessible site (such as QA/staging) unless you know what you're doing (else sensitive information may be revealed).
Sign up to request clarification or add additional context in comments.

1 Comment

Very good answer! I tried to fix this issue the way you described and i found that one plugin is causing this problem maby because is not following WordPress standars in my case was Smart Slider 3 Pro ? , but what happens if you set this to null ? I tried to run the code you described and i works then i put the old code again and the error was gone i think is something with the Transients i have read this article to thetwopercent.co.uk/… and they talk about deleting Transients.
1

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>' );

2 Comments

The above solution allowed me to pinpoint which plugin was causing the issue for my case. In my case it was yoast-seo-wordpress-premium. After deleting the plugin the issue error notice was still showing, however, after deleting transients from the databast, the error was gone. Running the queries for deleting transients directly on the database helps to avoid having to install a plugin to clear transients: DELETE FROM wp_options` WHERE option_name LIKE ('_transient_%'); DELETE FROM wp_options WHERE option_name LIKE ('_site_transient_%');`
Just adding to my comment above: Yoast SEO Premium support came back with a helpful answer, they confirmed that the issue is in their plugin and they are going to fix it in a future release. In the meantime, they gave the following workaround: "You can disable the WordPress debug mode and that shall hide the relevant warning without affecting anything on your website. Alternatively, you can ignore the relevant warning since you're running your website on localhost; production sites are typically not running with the debug mode enabled."
0

Try to update your wordpress by : Dashboard -> Update and if you have the last version try to reinstall it and your problem will be solve

3 Comments

i have updated it , my current version is 4.9.2 , the problem persists
so u should desactive all the plugins and test or set the default template of wp
i tried with twenty sixteen either deactivate plugins nothing change
0

Try to update all of your plugins that has update available. That solved my issue.

1 Comment

(This post does not seem to provide a quality answer to the question. Please either edit your answer and improve it, or just post it as a comment to the question.)
0

goto /wp-includes/class-wp-list-util.php find the public function pluck function and then replace this section.

foreach ( $this->output as $key => $value ) {
                if ( is_object( $value ) ) {
                    if(isset($value->$field)){
                        $newlist[ $key ] = $value->$field;
                    }

Sure this will not work if you update your wordpress later you have to redo this.But you're updating the core here because you have to and have no other choice not because you want to.In my case the error is caused by the elementor plugin.

Comments

0

Warning: Undefined property: stdClass::$plugin in C:\xampp\htdocs\Dressbarn\wp-includes\class-wp-list-util.php on line 166 whne this error message shows in my dashboard--------solution--- Updating all plugin helps this type of message was gone.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.