mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-27 06:42:56 +02:00
Add a TTL to core update checks to allow us to narrow the 12-hour update window.
props dd32. fixes #27772. Built from https://develop.svn.wordpress.org/trunk@28129 git-svn-id: http://core.svn.wordpress.org/trunk@27960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
da896b7cf3
commit
3b50cf7ec2
@ -154,6 +154,19 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
||||
$updates->translations = $body['translations'];
|
||||
|
||||
set_site_transient( 'update_core', $updates );
|
||||
|
||||
if ( ! empty( $body['ttl'] ) ) {
|
||||
$ttl = (int) $body['ttl'];
|
||||
if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
|
||||
// Queue an event to re-run the update check in $ttl seconds.
|
||||
wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger a background updates check if running non-interactively, and we weren't called from the update handler.
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
|
||||
do_action( 'wp_maybe_auto_update' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,8 +216,12 @@ function wp_update_plugins( $extra_stats = array() ) {
|
||||
$timeout = HOUR_IN_SECONDS;
|
||||
break;
|
||||
default :
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
$timeout = 0;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
|
||||
|
||||
@ -349,8 +366,12 @@ function wp_update_themes( $extra_stats = array() ) {
|
||||
$timeout = HOUR_IN_SECONDS;
|
||||
break;
|
||||
default :
|
||||
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
||||
$timeout = 0;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user