[wp-trac] [WordPress Trac] #50852: Site Health applies auto_update_theme filter incorrectly

WordPress Trac noreply at wordpress.org
Wed Aug 5 05:24:05 UTC 2020


#50852: Site Health applies auto_update_theme filter incorrectly
--------------------------+-----------------------------
 Reporter:  bpayton       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Site Health   |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The `auto_update_{type}` filters are [https://github.com/WordPress
 /wordpress-develop/blob/581a636badd142fe37cf2d07b2bd21d5f904d99f/src/wp-
 admin/includes/class-wp-automatic-updater.php#L195-L197 documented to take
 an item object], but the `WP_Debug_Data` class, used by the Site Health
 page, passes an array instead.

 This leads to PHP notices for existing `auto_update_theme` filters which
 treat the item argument as an object. For example,
 [https://github.com/Automattic/jetpack/blob/14dada52402ee49c062ce2ee99c09b56f653e0f8/class
 .jetpack-autoupdate.php#L93 here is a Jetpack filter] that treats the item
 argument as an object and triggers a PHP notice on the Site Health
 information page:

 ''[04-Aug-2020 23:07:30 UTC] PHP Notice:  Trying to get property 'theme'
 of non-object in /srv/htdocs/wp-content/plugins/jetpack/class.jetpack-
 autoupdate.php on line 93''

 **How is it broken?**

 Both the Site Health page and the theme update logic consume the
 `update_themes` transient as a representation of which themes need updates
 and which do not. When the information is retrieved, each theme is
 represented by an array. The `WP_Automatic_Updater` class casts each theme
 array to an object prior to attempting an update
 [https://github.com/WordPress/wordpress-
 develop/blob/581a636badd142fe37cf2d07b2bd21d5f904d99f/src/wp-
 admin/includes/class-wp-automatic-updater.php#L447-L450 here],
 and because of this, when the class applies the `auto_update_theme`
 filter, it passes an item object.

 In contrast, the Site Health information page, specifically the
 `WP_Debug_Data` class, doesn't cast the theme item array to an object
 before it applies `auto_update_theme` [https://github.com/WordPress
 /wordpress-develop/blob/581a636badd142fe37cf2d07b2bd21d5f904d99f/src/wp-
 admin/includes/class-wp-debug-data.php#L1102-L1118 here],
 [https://github.com/WordPress/wordpress-
 develop/blob/581a636badd142fe37cf2d07b2bd21d5f904d99f/src/wp-
 admin/includes/class-wp-debug-data.php#L1189-L1205 here], and
 [https://github.com/WordPress/wordpress-
 develop/blob/581a636badd142fe37cf2d07b2bd21d5f904d99f/src/wp-
 admin/includes/class-wp-debug-data.php#L1278-L1294 here].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50852>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list