Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#43103 closed defect (bug) (fixed)

Reduce Plugin/theme API calls during core release windows

Reported by: dd32's profile dd32 Owned by: dd32's profile dd32
Milestone: 4.9.4 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: fixed-major
Focuses: Cc:

Description

During WordPress security release windows we reduce the API TTL to cause WordPress to check for updates more often. This allows us to roll out security patches in a shorter timeframe (instead of over ~12-24hrs).

One unfortunately side effect of having the core check run more often, is that it triggers both the plugin and theme update checks to occur as well. This isn't normally an issue, however the plugin & theme update checks are relatively heavy calls which we can't simply cache, combine that with sites checking in every ~hour and WordPress.org's load increases dramatically.

This happens as we trigger an auto-update attempt after each core update check, which then causes a plugin and theme update check to trigger (as they have their caches disabled during cron requests) as they're also part of auto-updates.

The attached patch attempts to do two things:

  1. When checking for core updates, only trigger auto-updates if one actually exists and can be updated to. This is separate from the twice-daily auto-update cron task.
  2. Increases the cache timeout for plugins and themes in cron from 0 seconds to 2 hours.

I don't know how much (if any) impact 2. will have, however I don't think it'll cause any noticeable issues, and re-using a cache from the last 2 hours on a twice-daily cron seems entirely reasonable to me. The only reason cron has a lower cache timeout is that it's not as much of an issue if the request is slow, as it's running non-interactively.

Attachments (1)

43103.diff (5.4 KB) - added by dd32 7 years ago.

Download all attachments as: .zip

Change History (7)

@dd32
7 years ago

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


7 years ago

#2 @dd32
7 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 42584:

Updates: Only trigger Background Update processes from within the core update check when a core autoupdate is on offer.

This change reduces the number of API calls which WordPress makes to api.wordpress.org during release windows.

Previously the background updates would run upon every core update transient refresh, however now they'll only run if there's an update available.
The change also increases the cache period for plugin & theme checks when running via the cron, from never-cache to 2 hours, which should hopefully reduce the number of needless API calls.

Fixes #43103 for trunk.

#3 @dd32
7 years ago

In 42586:

Updates: Only trigger Background Update processes from within the core update check when a core autoupdate is on offer.

This change reduces the number of API calls which WordPress makes to api.wordpress.org during release windows.

Previously the background updates would run upon every core update transient refresh, however now they'll only run if there's an update available.
The change also increases the cache period for plugin & theme checks when running via the cron, from never-cache to 2 hours, which should hopefully reduce the number of needless API calls.

Merges [42584] to the 4.9 branch.
Fixes #43103 for 4.9.

#4 @dd32
7 years ago

In 42653:

Updates: Partially revert [42584], as this branch of code should always be run after a core update check.

This code branch is responsible for running all autoupdates, including plugins and themes - which should run regardless of if there's a core autoupdate available.

This revert does not revert the $timeout changes, as these should still use cached data if it's available.
Ideally this should be decoupled from the core update check to allow background updates to operate even when the core update check is disabled or running more often than twice daily.

See #43103.

#5 @dd32
7 years ago

  • Keywords fixed-major added
  • Milestone changed from 4.9.3 to 4.9.4
  • Resolution fixed deleted
  • Status changed from closed to reopened

This hasn't quite had the intended effect, so lets revert and take another try at it later.

#6 @dd32
7 years ago

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

In 42654:

Updates: Partially revert [42584], as this branch of code should always be run after a core update check.

This code branch is responsible for running all autoupdates, including plugins and themes - which should run regardless of if there's a core autoupdate available.

This revert does not revert the $timeout changes, as these should still use cached data if it's available.
Ideally this should be decoupled from the core update check to allow background updates to operate even when the core update check is disabled or running more often than twice daily.

Merges [42653] to the 4.9 branch.
Fixes #43103, #43235.

Note: See TracTickets for help on using tickets.