[wp-trac] [WordPress Trac] #44118: WordPress performs some unnecessary plugin update checks

WordPress Trac noreply at wordpress.org
Tue Mar 4 11:40:00 UTC 2025


#44118: WordPress performs some unnecessary plugin update checks
-------------------------------------+--------------------------
 Reporter:  siliconforks             |       Owner:  johnbillion
     Type:  defect (bug)             |      Status:  reviewing
 Priority:  normal                   |   Milestone:  6.8
Component:  Upgrade/Install          |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+--------------------------

Comment (by siliconforks):

 Replying to [comment:16 johnbillion]:
 > @siliconforks It looks you're right! Thanks a lot for the explanation.
 I'll carry on testing to confirm for sure, then hopefully we can get this
 in.

 Just a suggestion for you or anyone else who is reviewing/testing this: it
 may be helpful to compare the behavior of `wp_update_plugins()` to
 `wp_update_themes()`.  The code for the two functions is very similar - or
 at least, it was very similar originally, though it's diverged a lot over
 the years.

 The fundamental problem with `wp_update_plugins()` is that it's
 essentially trying to
 [https://en.wikipedia.org/wiki/Loop_fission_and_fusion jam] two different
 loops into one.  Conceptually, there are two separate loops here: there's
 a loop which goes through all plugins and determines whether any have
 changed since the last update, and there's another loop which populates
 the `checked` array which ultimately gets saved in the transient.  The
 issue with `wp_update_plugins()` is that it tries to do both these things
 in a single loop.  That doesn't really work here, because the loop which
 populates the `checked` array should ''always'' be executed, while the
 loop that determines whether any plugins have changed is sometimes skipped
 over entirely.

 In contrast, if you look at the code for `wp_update_themes()`, it doesn't
 have this issue.  There are two separate loops, one which populates the
 `checked` array, and one which goes through all the themes to see whether
 any have changed.

 My patch basically just attempts to split the code into two separate loops
 and make the behavior of `wp_update_plugins()` a little bit more like
 `wp_update_themes()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44118#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list