Make WordPress Core

Opened 12 months ago

Closed 8 weeks ago

Last modified 8 weeks ago

#61055 closed defect (bug) (fixed)

wp_update_plugins irregular transient handling.

Reported by: cybr's profile Cybr Owned by: johnbillion's profile johnbillion
Milestone: 6.8 Priority: normal
Severity: normal Version: 6.6
Component: Plugins Keywords: has-patch needs-testing needs-testing-info
Focuses: Cc:

Description

When creating $updates in wp_update_plugins(), its properties are populated immediately.

However, one property is missing, which is used later: checked.

When hooking into pre_set_site_transient_update_plugins, the checked property will be available sporadically because of this, depending on whether the $time_not_changed && ! $extra_stats branch is executed or not.

Another noteworthy issue with this function is that its implementation of set_site_transient( 'update_plugins', ... ); uses both the values $current and $updates. They store different objects at different times (1, 2).

Prepopulating both values with the same object properties would help prevent object-typing issues.

Change History (19)

#2 @SergeyBiryukov
12 months ago

  • Component changed from General to Plugins
  • Milestone changed from Awaiting Review to 6.6

This ticket was mentioned in PR #6736 on WordPress/wordpress-develop by @snehapatil02.


11 months ago
#3

  • Keywords has-patch added

### Ticket: https://core.trac.wordpress.org/ticket/61055

## Description
Ensure consistent handling of 'checked' property in wp_update_plugins() function.

  • This PR addresses the irregular handling of the transient in the wp_update_plugins() function, ensuring that the 'checked' property is always available when hooking into pre_set_site_transient_update_plugins.
  • It also ensures consistency between the $current and $updates objects, preventing potential issues caused by different object properties at different times.

## Changes Made

  • Initialize the 'checked' property in the $current object if it is not already set.
  • Ensure that the 'checked' property is always assigned to the $updates object.
  • Prepopulate both $current and $updates with the same 'checked' property to prevent object-typing issues.
  • Update the set_site_transient('update_plugins', $updates) to store the $updates object consistently.

siliconforks commented on PR #6736:


11 months ago
#4

Note that there is already an existing patch (which is intended to address this problem) in this ticket:

https://core.trac.wordpress.org/ticket/44118

#5 follow-up: @Cybr
11 months ago

This might be a duplicate of #44118; though addressing a different issue, its resolution appears to be the same.

#6 in reply to: ↑ 5 @siliconforks
11 months ago

Replying to Cybr:

This might be a duplicate of #44118; though addressing a different issue, its resolution appears to be the same.

#44118 basically has the same root cause - the checked property is missing from the transient, which causes additional (unnecessary) update checks to be performed.

This ticket was mentioned in Slack in #core by nhrrob. View the logs.


10 months ago

#8 @tremidkhar
10 months ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core by nhrrob. View the logs.


10 months ago

#10 @nhrrob
10 months ago

  • Milestone changed from 6.6 to 6.7

We are very close to RC1.
Looks like it still needs testing.
Punting to 6.7

This ticket was mentioned in Slack in #core by chaion07. View the logs.


7 months ago

#12 follow-up: @chaion07
7 months ago

  • Keywords needs-testing-info added

Thanks @Cybr for reporting this. We reviewed this Ticket during a recent bug-scrub session. Based on the feedback received we are adding the nedds-testing-info keyword to help with anyone hoping to run the tests. Thanks.

Props to @pratiklondhe

Cheers!

#13 in reply to: ↑ 12 @siliconforks
7 months ago

Replying to chaion07:

Thanks @Cybr for reporting this. We reviewed this Ticket during a recent bug-scrub session. Based on the feedback received we are adding the nedds-testing-info keyword to help with anyone hoping to run the tests. Thanks.

Have you looked at #44118 ? There are fairly detailed steps for reproducing this issue there. Basically, to test a patch, you would need to run steps 1 and 2 before and after applying the patch. (You could also look directly at the update_plugins transient before running step 2. Without any patch, you will see that it is missing a checked property. A working patch should fix this so that it always has the checked property.)

#14 @desrosj
6 months ago

  • Milestone changed from 6.7 to 6.8

With 6.7 RC1 due out any moment, this one unfortunately missed out. I've gone and moved #44118 to the 6.8 milestone along with this one to get these resolved.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


2 months ago

#16 @johnbillion
2 months ago

  • Owner set to johnbillion
  • Status changed from new to reviewing

This ticket was mentioned in Slack in #core-test by krupajnanda. View the logs.


2 months ago

#18 @johnbillion
8 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 59926:

Upgrade/Install: Prevent an unnecessary plugin update check when the plugin update data is up to date.

This ensures the checked property is always populated with the latest plugin data before determining whether to perform an update check. Previously this was only populated when the data was already identified as being stale, which could result in a subsequent unnecessary update check when viewing the Plugins screen.

Props siliconforks, bookdude13, pbiron, francina, Cybr, snehapatil02, johnbillion

Fixes #44118, #61055

@johnbillion commented on PR #6736:


8 weeks ago
#19

This was fixed in r59926 with a slightly different approach. Cheers!

Note: See TracTickets for help on using tickets.