WordPress Core Automatic Updates: Switch to a twicedaily cronjob to match the update check cron jobs, this removes the ability for update checks to continuously re-queue a upgrade job. See #22704

Built from https://develop.svn.wordpress.org/trunk@25466


git-svn-id: http://core.svn.wordpress.org/trunk@25387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-09-17 02:26:09 +00:00
parent 6655f30fd9
commit dfc708333f

View File

@ -120,8 +120,6 @@ function wp_version_check() {
$updates->last_checked = time();
$updates->version_checked = $wp_version;
set_site_transient( 'update_core', $updates);
wp_auto_updates_maybe_queue( 'core' );
}
/**
@ -223,8 +221,6 @@ function wp_update_plugins() {
$new_option->response = array();
set_site_transient( 'update_plugins', $new_option );
wp_auto_updates_maybe_queue( 'plugins' );
}
/**
@ -335,46 +331,14 @@ function wp_update_themes() {
$new_update->response = $response;
set_site_transient( 'update_themes', $new_update );
wp_auto_updates_maybe_queue( 'themes' );
}
/**
* Queues a cron entry if a potentially upgrade is detected.
* Cron entry which runs the WordPress Automatic Updates
*
* @since 3.7.0
*
* @param string $type The type of update to check for, may be 'core', 'plugins', or, 'themes'.
*/
function wp_auto_updates_maybe_queue( $type = 'core' ) {
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . '/wp-admin/includes/update.php';
if ( WP_Automatic_Upgrader::upgrader_disabled() )
return;
$updates_available = false;
if ( 'core' == $type ) {
$updates_available = (bool) find_core_auto_update();
} elseif ( 'plugins' == $type ) {
$plugin_updates = get_site_transient( 'update_plugins' );
$updates_available = !empty( $plugin_updates->response );
} elseif ( 'themes' == $type ) {
$theme_updates = get_site_transient( 'update_themes' );
$updates_available = empty( $theme_updates->response );
}
if ( $updates_available && ! wp_next_scheduled( 'wp_auto_updates_execute' ) ) {
// If the transient update was triggered by a user pageview, update in an hours time, else, now.
$when_to_update = get_current_user_id() ? time() + HOUR_IN_SECONDS : time();
$when_to_update = apply_filters( 'auto_upgrade_when_to_upgrade', $when_to_update );
wp_schedule_single_event( $when_to_update, 'wp_auto_updates_execute' );
}
}
function wp_auto_updates_execute() {
function wp_auto_updates_maybe_update() {
include_once ABSPATH . '/wp-admin/includes/admin.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
@ -487,6 +451,10 @@ function wp_schedule_update_checks() {
if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
if ( !wp_next_scheduled( 'wp_auto_updates_maybe_update' ) && ! defined( 'WP_INSTALLING' ) )
wp_schedule_event( time(), 'twicedaily', 'wp_auto_updates_maybe_update' );
}
if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
@ -508,6 +476,6 @@ add_action( 'admin_init', '_maybe_update_themes' );
add_action( 'wp_update_themes', 'wp_update_themes' );
// Automatic Updates - Cron callback
add_action( 'wp_auto_updates_execute', 'wp_auto_updates_execute' );
add_action( 'wp_auto_updates_maybe_update', 'wp_auto_updates_maybe_update' );
add_action('init', 'wp_schedule_update_checks');