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:
Andrew Nacin 2014-04-15 02:23:16 +00:00
parent da896b7cf3
commit 3b50cf7ec2
1 changed files with 24 additions and 3 deletions

View File

@ -153,7 +153,20 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
if ( isset( $body['translations'] ) ) if ( isset( $body['translations'] ) )
$updates->translations = $body['translations']; $updates->translations = $body['translations'];
set_site_transient( 'update_core', $updates); 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,7 +216,11 @@ function wp_update_plugins( $extra_stats = array() ) {
$timeout = HOUR_IN_SECONDS; $timeout = HOUR_IN_SECONDS;
break; break;
default : default :
$timeout = 12 * HOUR_IN_SECONDS; 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 ); $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
@ -349,7 +366,11 @@ function wp_update_themes( $extra_stats = array() ) {
$timeout = HOUR_IN_SECONDS; $timeout = HOUR_IN_SECONDS;
break; break;
default : default :
$timeout = 12 * HOUR_IN_SECONDS; 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 ); $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );