WordPress.org

Make WordPress Core

Changeset 25466


Ignore:
Timestamp:
09/17/13 02:25:17 (4 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r25442 r25466  
    121121    $updates->version_checked = $wp_version; 
    122122    set_site_transient( 'update_core',  $updates); 
    123  
    124     wp_auto_updates_maybe_queue( 'core' ); 
    125123} 
    126124 
     
    224222 
    225223    set_site_transient( 'update_plugins', $new_option ); 
    226  
    227     wp_auto_updates_maybe_queue( 'plugins' ); 
    228224} 
    229225 
     
    336332 
    337333    set_site_transient( 'update_themes', $new_update ); 
    338  
    339     wp_auto_updates_maybe_queue( 'themes' ); 
    340 } 
    341  
    342 /** 
    343  * Queues a cron entry if a potentially upgrade is detected. 
     334} 
     335 
     336/** 
     337 * Cron entry which runs the WordPress Automatic Updates 
    344338 * 
    345339 * @since 3.7.0 
    346  * 
    347  * @param string $type The type of update to check for, may be 'core', 'plugins', or, 'themes'. 
    348  */ 
    349 function wp_auto_updates_maybe_queue( $type = 'core' ) { 
    350     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 
    351     include_once ABSPATH . '/wp-admin/includes/update.php'; 
    352  
    353     if ( WP_Automatic_Upgrader::upgrader_disabled() ) 
    354         return; 
    355  
    356     $updates_available = false; 
    357     if ( 'core' == $type ) { 
    358         $updates_available = (bool) find_core_auto_update(); 
    359     } elseif ( 'plugins' == $type ) { 
    360         $plugin_updates = get_site_transient( 'update_plugins' ); 
    361         $updates_available = !empty( $plugin_updates->response ); 
    362     } elseif ( 'themes' == $type ) { 
    363         $theme_updates = get_site_transient( 'update_themes' ); 
    364         $updates_available = empty( $theme_updates->response ); 
    365     } 
    366  
    367     if ( $updates_available && ! wp_next_scheduled( 'wp_auto_updates_execute' ) ) { 
    368         // If the transient update was triggered by a user pageview, update in an hours time, else, now. 
    369         $when_to_update = get_current_user_id() ? time() + HOUR_IN_SECONDS : time(); 
    370         $when_to_update = apply_filters( 'auto_upgrade_when_to_upgrade', $when_to_update ); 
    371  
    372         wp_schedule_single_event( $when_to_update, 'wp_auto_updates_execute' ); 
    373     } 
    374  
    375 } 
    376  
    377 function wp_auto_updates_execute() { 
     340 */ 
     341function wp_auto_updates_maybe_update() { 
    378342    include_once ABSPATH . '/wp-admin/includes/admin.php'; 
    379343    include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; 
     
    488452    if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') ) 
    489453        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes'); 
     454 
     455    if ( !wp_next_scheduled( 'wp_auto_updates_maybe_update' ) && ! defined( 'WP_INSTALLING' ) ) 
     456        wp_schedule_event( time(), 'twicedaily', 'wp_auto_updates_maybe_update' ); 
     457 
    490458} 
    491459 
     
    509477 
    510478// Automatic Updates - Cron callback 
    511 add_action( 'wp_auto_updates_execute', 'wp_auto_updates_execute' ); 
     479add_action( 'wp_auto_updates_maybe_update', 'wp_auto_updates_maybe_update' ); 
    512480 
    513481add_action('init', 'wp_schedule_update_checks'); 
Note: See TracChangeset for help on using the changeset viewer.