[wp-trac] [WordPress Trac] #25542: Function "set_site_transient" is executed twice for plugins - Is it necessary?

WordPress Trac noreply at wordpress.org
Tue Oct 8 22:07:56 UTC 2013


#25542: Function "set_site_transient" is executed twice for plugins - Is it
necessary?
-------------------------+-------------------------------------------------
 Reporter:               |      Owner:
  johnstonphilip         |     Status:  new
     Type:  enhancement  |  Milestone:  Awaiting Review
 Priority:  normal       |    Version:  3.6.1
Component:  Performance  |   Keywords:  2nd-opinion needs-testing dev-
 Severity:  trivial      |  feedback
-------------------------+-------------------------------------------------
 In the "wp-includes/update.php" file, the "set_site_transient" function is
 executed twice for 'update_plugins' on lines 195 and 217. This is causing
 a slowdown that may not need to exist when checking for new updates.

 In the "set_site_transient" function (found in the "wp-
 includes/option.php" file) there is a filter called
 "pre_set_site_transient_" which is used to hook new plugin updates.
 Because the "set_site_transient" function is called twice as outlined
 above, this filter also is called twice which means all of the functions
 attached to it get called twice as well.

 I tested removing the first call to it on line 195 and it doesn't appear
 to change anything in the multiple tests I have done.

 There is a comment above the call on line 195 which I don't understand and
 reads:
 "Update last_checked for current to prevent multiple blocking requests if
 request hangs".

 The problem with having this filter being called twice is that when doing
 custom API calls for plugin updates, it is checking the API twice for EACH
 plugin. This ends up increasing the time it takes to check for updates by
 double. If I have 10 plugins installed, that translates into 20 API
 checks.

 I feel like if there was a way around setting this transient twice, the
 amount of time it takes to do plugin updates could potentially be cut in
 half.

 I could be wrong so I'm wondering if anyone could test this as well to
 confirm.

 Sidenote: It is also executed twice for:
  - "update_core" (line 47 and line 120)
  - "update_themes" (line 302 and line 323)

 However, I have not yet tested removing the duplicate for these.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25542>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list