Opened 6 years ago
Last modified 5 months ago
#44582 new defect (bug)
Notice: Undefined property:stdClass::$plugin - wordpress
Reported by: | sangwan4pankaj | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9.7 |
Component: | Plugins | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
Notice: Undefined property: stdClass::$plugin in /hermes/bosnaweb07a/b1754/ipg.account_name/folder_name/wp-includes/class-wp-list-util.php on line 150
Change History (11)
#2
@
6 years ago
- Component changed from General to Plugins
I have just had this pop-up in my local wordpress install, when visiting the "wp-admin/plugin-install.php".
I believe this is caused by a "rogue" plugin which has a very different object registered with $installed_plugins
. In this case the "rogue" plugin is SearchWP--actually quite good bit of kit, aside from the fact that my windows dev box still cannot install upgrades of it because of the deeply nested structure and super-long filenames, but that is another ticket (#40795)...
If I dump $installed_plugins
at line 252 of class-wp-plugin-install-list-table.php
, I get a fairly neat (as in tidy) array where every plugin's object follows this pattern (using CMB2 as an example):
'cmb2' => object(stdClass)[1931] public 'id' => string 'w.org/plugins/cmb2' (length=18) public 'slug' => string 'cmb2' (length=4) public 'plugin' => string 'cmb2/init.php' (length=13) public 'new_version' => string '2.4.2' (length=5) public 'url' => string 'https://wordpress.org/plugins/cmb2/' (length=35) public 'package' => string 'https://downloads.wordpress.org/plugin/cmb2.zip' (length=47) public 'icons' => array (size=2) '2x' => string 'https://ps.w.org/cmb2/assets/icon-256x256.png?rev=1081087' (length=57) '1x' => string 'https://ps.w.org/cmb2/assets/icon-128x128.png?rev=1081087' (length=57) public 'banners' => array (size=2) '2x' => string 'https://ps.w.org/cmb2/assets/banner-1544x500.png?rev=1081087' (length=60) '1x' => string 'https://ps.w.org/cmb2/assets/banner-772x250.png?rev=1081087' (length=59) public 'banners_rtl' => array (size=0) empty public 'upgrade' => boolean false
Until we get to SearchWP, in this case version 2.9.13, where the object for it looks like this:
'searchwp' => object(stdClass)[1924] public 'new_version' => string '2.9.17' (length=6) public 'stable_version' => string '2.9.17' (length=6) public 'name' => string 'SearchWP' (length=8) public 'slug' => string 'searchwp' (length=8) public 'url' => string 'https://searchwp.com/downloads/searchwp/?changelog=1' (length=52) public 'last_updated' => string '2018-11-27 08:30:24' (length=19) public 'homepage' => string 'https://searchwp.com/downloads/searchwp/' (length=40) public 'package' => string 'https://searchwp.com/edd-sl/package_download/XXX0XXX3XXXxXxxxXXXxXXxxXXXxXxXxX1X1XXX1Xxx1XXXlxXXxX1XxXxx4XxXxXXXxXXXxXxXxXXX1XXXxXxx1Xxx1XXxxXXX1XxXXXxx0xXXXXx1xxXXxxX1xXXx1XX==' (length=177) public 'download_link' => string 'https://searchwp.com/edd-sl/package_download/XXX0XXX3XXXxXxxxXXXxXXxxXXXxXxXxX1X1XXX1Xxx1XXXlxXXxX1XxXxx4XxXxXXXxXXXxXxXxXXX1XXXxXxx1Xxx1XXxxXXX1XxXXXxx0xXXXXx1xxXXxxX1xXXx1XX==' (length=177) public 'sections' => object(stdClass)[1925] public 'description' => string '' (length=0) public 'changelog' => string '<p>2.9.17</p>'... (length=83111) public 'banners' => object(stdClass)[1926] public 'high' => string '' (length=0) public 'low' => string '' (length=0) public 'icons' => string 'a:0:{}' (length=6) public 'description' => array (size=1) 0 => string '' (length=0) public 'changelog' => array (size=1) 0 => string '<p>2.9.17</p>'... (length=83111) public 'upgrade' => boolean true
There is no plugin
property in this array, which is triggering the exception.
Here are the notices themselves:
( ! ) Notice: Undefined property: stdClass::$plugin in C:\wamp\www\wordpress\wp\wp-includes\class-wp-list-util.php on line 150 Call Stack # Time Memory Function Location 1 0.0008 396152 {main}( ) ...\plugin-install.php:0 2 1.8819 55825728 WP_Plugin_Install_List_Table->prepare_items( ) ...\plugin-install.php:39 3 2.3318 56485400 wp_list_pluck( ) ...\class-wp-plugin-install-list-table.php:253 4 2.3318 56485552 WP_List_Util->pluck( ) ...\functions.php:3662 ( ! ) Notice: Undefined property: stdClass::$plugin in C:\wamp\www\wordpress\wp\wp-includes\class-wp-list-util.php on line 150 Call Stack # Time Memory Function Location 1 0.0008 396152 {main}( ) ...\plugin-install.php:0 2 1.8819 55825728 WP_Plugin_Install_List_Table->prepare_items( ) ...\plugin-install.php:39 3 2.3401 56486504 wp_filter_object_list( ) ...\class-wp-plugin-install-list-table.php:254 4 2.3401 56487032 WP_List_Util->pluck( ) ...\functions.php:3612
I guess while this seems like a plugin-specific issue (I have no idea if the original poster was also working with SearchWP), either a plugin should not be included in this array without at least doing a check of the object properties, or perhaps the list pluck utility needs to do a check to see if the property exists before trying to grab it. SearchWP was otherwise able to be activated, and if that's the case I would not expect a plugin which passes that "test" to cause an error on the "install plugins" page.
Note that disabling the plugin does not make this go away (I assume that the purpose on this install screen is to hide or otherwise indicate to users plugins that may already be installed, so it makes sense that disabling this without uninstalling it would still cause the error.)
#8
@
3 years ago
Seeing this on PHP 8:
PHP Warning: Undefined property: stdClass::$plugin in \wp-admin\includes\class-wp-automatic-updater.php on line 170, referer: /wp-cron.php?doing_wp_cron=1624639377.2227780818939208984375
Using TwentyTwenty theme, all plugins disabled, and WordPress 5.7.2.
I discovered this was caused by a plugin leaving an empty cron running after it was disabled (actually two plugins Jetpack and WP Polls).
#9
@
3 years ago
As a temporal fix, I have added this filter in functions.php file. It basically checks the transients->response property, and foreach response, if the plugin property is missing, it adds it by picking the key, which is exactely what we need, since it is formed like this : plugin's directory name . '/' . plugin's init file . '.php'.
<?php add_filter('site_transient_update_plugins', function($transients) { if (!empty($transients->response)) { foreach ($transients->response as $key => $plugin) { if (!property_exists($plugin, "plugin")) { $transients->response[$key]->plugin = $key; } } } return $transients; });
This ticket was mentioned in Slack in #core by costdev. View the logs.
3 years ago
#11
@
5 months ago
Over the last few weeks, I have increasingly come across exactly these messages in the support forum, including
https://wordpress.org/support/topic/undefined-property-stdclassplugin-in-home-sites-85-site8660492-web-wp-incl/
https://wordpress.org/support/topic/undefined-property-stdclassplugin/
Even if the actual cause is probably one or more plugins, could @moxymore's adjustment be used as an optimization?
I would consider this to be a duplicate: https://core.trac.wordpress.org/ticket/59413
Hey sangwan4pankaj, welcome to Trac.
Please can you tell us where you are seeing this error message? Steps to reproduce would be very helpful. I think this coming from a core WordPress utility call for creating lists, but it may well also be in use from plugins or themes. The issue may therefore be with the plugin or theme rather than this being a core bug.