WordPress.org

Make WordPress Core

#27772 closed enhancement (fixed)

Add a TTL to Core update checks

Reported by: dd32 Owned by: nacin
Milestone: 3.9 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

Currently WordPress checks for a new version every 12 hours, and once per minute if you're hitting the updates page.

The attached patch introduces a TTL field in the core update response, this allows us to tell an install "Hey, there's an update coming out in the near future, can you please check for an updated version more often?".

The primary use of this would be to alert site administrators to an update as fast as possible, for example, if someone checks their Updates page at 10am, and we release an update at midday, presently they won't get an alert unless they view their updates page again, or visit their site again after 10pm.

Attachments (2)

27772.diff (2.0 KB) - added by dd32 12 months ago.
27772.2.diff (4.3 KB) - added by dd32 12 months ago.

Download all attachments as: .zip

Change History (9)

@dd3212 months ago

comment:1 @dd3212 months ago

27772.diff includes some debug to trigger the check every 90seconds, using a plugin which lets you view cron tasks, reloading that page should show the event running and being re-queued.

The patch also contains a command to re-run Background updates after a version check has completed, however, this has a side effect of Background Update will now be run a minimum of 4 times daily, 7am/pm + a random hour of the day when the core version check is queued.

This does however also mean that in the event that we utilise the TTL to make WordPress re-check more often, we can have as many sites updated as fast as possible rather than waiting up to 12hours for all installs to get the message.

This change will not help plugin security updates though, as they will still only be checked every 12 hours (Even if the background update callback is kicked off more often than that) as wp_update_plugins() has a 12hour timeout on it. We could reduce that timeout to 1hour for cron tasks though perhaps.

Last edited 12 months ago by dd32 (previous) (diff)

@dd3212 months ago

comment:2 @dd3212 months ago

This change will not help plugin security updates though, as they will still only be checked every 12 hours (Even if the background update callback is kicked off more often than that) as wp_update_plugins() has a 12hour timeout on it. We could reduce that timeout to 1hour for cron tasks though perhaps.

27772.2.diff does this, if wp_update_plugins() is running within cron, we expect it to make a new request, so it drops the timeout to 0. (This also applies to themes)

Last edited 12 months ago by dd32 (previous) (diff)

comment:3 @Denis-de-Bernardy12 months ago

With respect to:

// Testing only, causes an update cron task to be run every 90seconds 
$body['ttl'] = 90; 

Perhaps it's a sign that the API is missing a couple of hooks? :-)

comment:4 @dd3212 months ago

Perhaps it's a sign that the API is missing a couple of hooks? :-)

Perhaps it's just a sign that it's easier to add an extra API response field next to the code being tested, rather than having everyone modify the API response they see? (either by modifying the server code being hit, or filtering something)

comment:5 @Denis-de-Bernardy12 months ago

Hehe. I understand your reasoning, it's just that reading the two lines triggered a vivid reminder in me of how a few strategically placed hooks in the update API would be welcome.

In essence, if you as a core dev could easily test the ttl argument and similar using a plugin instead of by inserting debug code within the WP trunk, odds are that we plugin devs could more easily work with the update API. Related: #27124.

comment:6 @nacin12 months ago

  • Milestone changed from Awaiting Review to 3.9

comment:7 @nacin12 months ago

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

In 28129:

Add a TTL to core update checks to allow us to narrow the 12-hour update window.

props dd32.
fixes #27772.

Note: See TracTickets for help on using tickets.