Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#64775 closed defect (bug) (duplicate)

Warning from pluck function on some random pages

Reported by: gautammkgarg Owned by:
Priority: normal Milestone:
Component: General Version: 4.7
Severity: normal Keywords: has-patch needs-unit-tests reporter-feedback
Cc: Focuses:

Description

While using WordPress 7.0-beta2, I was getting warnings on some random WordPress admin pages. I made a minor change to fix it and raised the PR.

PHP Warning:  Undefined property: stdClass::$plugin in \wp-includes\class-wp-list-util.php on line 168

Pull Request: ​https://github.com/WordPress/WordPress/pull/784

Attachments (2)

Screenshot 2026-03-04 025330.png​ (209.6 KB ) - added by gautammkgarg 8 months ago.
Screenshot 2026-03-04 030101.png​ (148.9 KB ) - added by gautammkgarg 8 months ago.
Exception in Visual Studio Code

Download all attachments as: .zip

Change History (12)

This ticket was mentioned in ​PR #11115 on ​WordPress/wordpress-develop by ​@gautammkgarg.


8 months ago
#1

  • Keywords has-patch added

Add property_exists check before accessing field.
Fixed warning in PHP.

PHP Warning:  Undefined property: stdClass::$plugin in \wp-includes\class-wp-list-util.php on line 168

Trac ticket: https://core.trac.wordpress.org/ticket/64775

#2 @mukesh27
8 months ago

  • Component Plugins → General
  • Focuses administration coding-standards php-compatibility removed
  • Keywords needs-unit-tests added
  • Version trunk → 4.7

Hi there! Welcome to Trac 👋

Thanks for the ticket and the PR, much appreciated!

Could you please add unit tests that verify the expected behavior? It would also be helpful to include clear testing instructions in the ticket description so others can easily reproduce and validate the issue.

That will make the review process much smoother. Thanks again!

#3 @westonruter
8 months ago

  • Keywords reporter-feedback added

Nevertheless, how would a developer discover that they are requesting an invalid key for the array of objects/arrays? What underlying code was attempting to pluck the plugin property?

#5 follow-up: @westonruter
8 months ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #59774.

Thanks for that. Closing as duplicate.

#6 in reply to: ↑ 5 ; follow-up: @siliconforks
8 months ago

Replying to westonruter:

Duplicate of #59774.

Thanks for that. Closing as duplicate.

I'm not sure I would call this a duplicate... I wouldn't recommend trying to change the pluck() function (because it was tried before and it caused regressions), but shouldn't we still try to figure out what code is looking for the plugin property and triggering the warning (like you said in this comment above)?

@gautammkgarg - can you describe the exact steps needed to reproduce these warnings? Which admin pages are you seeing these warnings on?

#7 in reply to: ↑ 6 @gautammkgarg
8 months ago

I was getting this warning on some random pages. Today I tried to replicate the issue again but today I am not getting the warnings. I don't remember on what pages I was getting the error. But what I do remember is that $value of below code was having data of few plugins, One of them was Angelleye Updater: ​https://github.com/angelleye/angelleye-updater, if I remember is correctly.

					$newlist[ $key ] = $value->$field;

As I am not getting this error everytime, so I am assuming that it might be triggered from some scheduler.

Replying to siliconforks:

@gautammkgarg - can you describe the exact steps needed to reproduce these warnings? Which admin pages are you seeing these warnings on?

#8 @gautammkgarg
8 months ago

Hello @siliconforks, @westonruter and @mukesh27

I again got the same warning. This time I have saved more information that might help you further in debugging.

I am getting this error on "Add Plugin" page ie "/wp-admin/plugin-install.php"

I have the full stack trace with me, but WordPress is not allowing me to submit it here. If you need it, please tell me the steps to provide the full stack trace.

During the warning, value of the $value was

class stdClass { public $slug = 'angelleye-updater'; public $upgrade = FALSE }

and the value of $field was "plugin"

I also tried deactivating and activating the 'angelleye-updater' plugin after I see this warning. After reactivation the error go away.

Kindly refer attached screenshots.

#9 follow-up: @siliconforks
8 months ago

I was able to reproduce this with the following steps:

  1. Install the Angell EYE Updater plugin by cloning the repository at ​https://github.com/angelleye/angelleye-updater
  1. Activate the plugin
  1. You might need WP_DEBUG set to true in your wp-config.php file
  1. Go to Dashboard → Updates. (This should trigger a check for updates, which is necessary to reproduce the issue.)
  1. Go to Plugins → Add Plugin.

If it doesn't work it may be because WordPress will not check for updates more often than once every minute. Simply wait for at least 1 minute and then repeat steps 4 and 5 again.

It looks like this issue is specific to the Angell EYE Updater plugin. It adds a pre_set_site_transient_update_plugins filter to modify the update_plugins transient, and when it does this it creates an object which has only a slug property (and therefore it has no plugin property, so you end up getting the warning Undefined property: stdClass::$plugin):

​https://github.com/angelleye/angelleye-updater/blob/v2.0.22/includes/class-angelleye-updater-update-checker.php#L135-L137

#10 in reply to: ↑ 9 @gautammkgarg
8 months ago

Thanks @siliconforks for investigating this issue further and providing more detailed steps to replicate the issue.

Replying to siliconforks:

It looks like this issue is specific to the Angell EYE Updater plugin. It adds a pre_set_site_transient_update_plugins filter to modify the update_plugins transient, and when it does this it creates an object which has only a slug property (and therefore it has no plugin property, so you end up getting the warning Undefined property: stdClass::$plugin):

Good observation. It looks like the issue is due to wrong code of "Angell Eye Update" plugin because most of the plugins are not triggering this warning.

It's not under WordPress' control how developers write the code for their plugins or theme. But the warning which we get in the logs or screen is making user confused. With the error message, it's difficult to understand if the issue is at WordPress' end or at Plugin's/Theme's end.

We can trigger the warning even by executing this code

wp_list_pluck([
        (object)[]
], 'any_key');

Looks like the other similar ticket (https://core.trac.wordpress.org/ticket/59774) is currently on paused status.

In my opinion, the suggestions by @westonruter should be merged, as this will handle the warning without impacting the existing functionality.

  1. ​https://github.com/WordPress/wordpress-develop/pull/11115/changes/91716f77cb3226721f508341c7cf6ab949e98d80
  1. ​https://github.com/WordPress/wordpress-develop/pull/11115/changes/31a638613ca0cc79ff9beb674cc9130969d7f193
Note: See TracTickets for help on using tickets.