Rami bellili
Rami bellili

Reputation: 67

stdClass wordpress plugin error

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 ?

Upvotes: 2

Views: 17858

Answers (6)

Mahbub
Mahbub

Reputation: 1

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.

Upvotes: 0

Wilmar Arias
Wilmar Arias

Reputation: 306

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

Upvotes: 1

Steve Moretz
Steve Moretz

Reputation: 3158

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.

Upvotes: 0

danielh
danielh

Reputation: 354

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).

Upvotes: 7

Ross
Ross

Reputation: 1

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

Upvotes: 0

Ibrahim Haouari
Ibrahim Haouari

Reputation: 250

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

Upvotes: 0

Related Questions