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. Built from https://develop.svn.wordpress.org/trunk@42584 git-svn-id: http://core.svn.wordpress.org/trunk@42413 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3429cfeabe
commit
14068105f7
|
@ -174,6 +174,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||
}
|
||||
|
||||
$offers = $body['offers'];
|
||||
$has_auto_update = false;
|
||||
|
||||
foreach ( $offers as &$offer ) {
|
||||
foreach ( $offer as $offer_key => $value ) {
|
||||
|
@ -207,6 +208,10 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||
), ''
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'autoupdate' == $offer->response ) {
|
||||
$has_auto_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
$updates = new stdClass();
|
||||
|
@ -229,9 +234,14 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||
}
|
||||
|
||||
// Trigger background updates if running non-interactively, and we weren't called from the update handler.
|
||||
if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) {
|
||||
if ( $doing_cron && $has_auto_update && ! doing_action( 'wp_maybe_auto_update' ) ) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/update.php' );
|
||||
|
||||
// Only trigger background updates if an acceptable autoupdate is on offer, avoids needless extra API calls.
|
||||
if ( find_core_auto_update() ) {
|
||||
do_action( 'wp_maybe_auto_update' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,7 +297,7 @@ function wp_update_plugins( $extra_stats = array() ) {
|
|||
break;
|
||||
default:
|
||||
if ( $doing_cron ) {
|
||||
$timeout = 0;
|
||||
$timeout = 2 * HOUR_IN_SECONDS;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
|
@ -474,7 +484,11 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||
$timeout = HOUR_IN_SECONDS;
|
||||
break;
|
||||
default:
|
||||
$timeout = $doing_cron ? 0 : 12 * HOUR_IN_SECONDS;
|
||||
if ( $doing_cron ) {
|
||||
$timeout = 2 * HOUR_IN_SECONDS;
|
||||
} else {
|
||||
$timeout = 12 * HOUR_IN_SECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42582';
|
||||
$wp_version = '5.0-alpha-42584';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue