Make WordPress Core

Changeset 36184


Ignore:
Timestamp:
01/06/2016 12:23:15 PM (9 years ago)
Author:
dd32
Message:

Background Updates: Remove the 7am/7pm background update check.

This changeset is a more basic version of [36180], clearing the extra now redundant schedule.
As the functionality for this was introduced in 3.9, [28129] has been backported to 3.7/3.8, allowing the API TTL to be respected by those versions.

See #27772.
Fixes #35323.

Location:
branches
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-includes/update.php

    r27930 r36184  
    147147        $updates->translations = $body['translations'];
    148148
    149     set_site_transient( 'update_core',  $updates);
     149    set_site_transient( 'update_core', $updates );
     150
     151    if ( ! empty( $body['ttl'] ) ) {
     152        $ttl = (int) $body['ttl'];
     153        if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
     154            // Queue an event to re-run the update check in $ttl seconds.
     155            wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
     156        }
     157    }
     158
     159    // Trigger background updates if running non-interactively, and we weren't called from the update handler.
     160    if ( defined( 'DOING_CRON' ) && DOING_CRON && 'wp_maybe_auto_update' != current_filter() ) {
     161        do_action( 'wp_maybe_auto_update' );
     162    }
    150163}
    151164
     
    198211            break;
    199212        default :
    200             $timeout = 12 * HOUR_IN_SECONDS;
     213            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     214                $timeout = 0;
     215            } else {
     216                $timeout = 12 * HOUR_IN_SECONDS;
     217            }
    201218    }
    202219
     
    345362            break;
    346363        default :
    347             $timeout = 12 * HOUR_IN_SECONDS;
     364            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     365                $timeout = 0;
     366            } else {
     367                $timeout = 12 * HOUR_IN_SECONDS;
     368            }
    348369    }
    349370
     
    586607        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    587608
    588     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    589         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    590         $next = strtotime( 'today 7am' );
    591         $now = time();
    592         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    593         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    594             $next += 12 * HOUR_IN_SECONDS;
    595         }
    596         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    597         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    598         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    599         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    600     }
     609    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     610        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    601611}
    602612
  • branches/3.8

  • branches/3.8/src/wp-includes/update.php

    r27929 r36184  
    155155        $updates->translations = $body['translations'];
    156156
    157     set_site_transient( 'update_core',  $updates);
     157    set_site_transient( 'update_core', $updates );
     158
     159    if ( ! empty( $body['ttl'] ) ) {
     160        $ttl = (int) $body['ttl'];
     161        if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
     162            // Queue an event to re-run the update check in $ttl seconds.
     163            wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
     164        }
     165    }
     166
     167    // Trigger background updates if running non-interactively, and we weren't called from the update handler.
     168    if ( defined( 'DOING_CRON' ) && DOING_CRON && 'wp_maybe_auto_update' != current_filter() ) {
     169        do_action( 'wp_maybe_auto_update' );
     170    }
    158171}
    159172
     
    206219            break;
    207220        default :
    208             $timeout = 12 * HOUR_IN_SECONDS;
     221            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     222                $timeout = 0;
     223            } else {
     224                $timeout = 12 * HOUR_IN_SECONDS;
     225            }
    209226    }
    210227
     
    353370            break;
    354371        default :
    355             $timeout = 12 * HOUR_IN_SECONDS;
     372            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     373                $timeout = 0;
     374            } else {
     375                $timeout = 12 * HOUR_IN_SECONDS;
     376            }
    356377    }
    357378
     
    594615        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    595616
    596     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    597         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    598         $next = strtotime( 'today 7am' );
    599         $now = time();
    600         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    601         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    602             $next += 12 * HOUR_IN_SECONDS;
    603         }
    604         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    605         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    606         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    607         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    608     }
     617    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     618        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    609619}
    610620
  • branches/3.9/src/wp-includes/update.php

    r28145 r36184  
    612612        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    613613
    614     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    615         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    616         $next = strtotime( 'today 7am' );
    617         $now = time();
    618         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    619         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    620             $next += 12 * HOUR_IN_SECONDS;
    621         }
    622         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    623         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    624         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    625         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    626     }
     614    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     615        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    627616}
    628617
  • branches/4.0/src/wp-includes/update.php

    r29226 r36184  
    634634        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    635635
    636     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    637         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    638         $next = strtotime( 'today 7am' );
    639         $now = time();
    640         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    641         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    642             $next += 12 * HOUR_IN_SECONDS;
    643         }
    644         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    645         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    646         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    647         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    648     }
     636    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     637        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    649638}
    650639
  • branches/4.1/src/wp-includes/update.php

    r31394 r36184  
    634634        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    635635
    636     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    637         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    638         $next = strtotime( 'today 7am' );
    639         $now = time();
    640         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    641         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    642             $next += 12 * HOUR_IN_SECONDS;
    643         }
    644         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    645         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    646         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    647         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    648     }
     636    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     637        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    649638}
    650639
  • branches/4.2/src/wp-includes/update.php

    r31825 r36184  
    634634        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    635635
    636     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    637         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    638         $next = strtotime( 'today 7am' );
    639         $now = time();
    640         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    641         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    642             $next += 12 * HOUR_IN_SECONDS;
    643         }
    644         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    645         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    646         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    647         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    648     }
     636    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     637        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    649638}
    650639
  • branches/4.3/src/wp-includes/update.php

    r32635 r36184  
    646646        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    647647
    648     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
    649         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    650         $next = strtotime( 'today 7am' );
    651         $now = time();
    652         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    653         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    654             $next += 12 * HOUR_IN_SECONDS;
    655         }
    656         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    657         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    658         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    659         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    660     }
     648    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! defined('WP_INSTALLING') )
     649        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    661650}
    662651
  • branches/4.4/src/wp-includes/update.php

    r35774 r36184  
    647647        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    648648
    649     if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! wp_installing() ) {
    650         // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
    651         $next = strtotime( 'today 7am' );
    652         $now = time();
    653         // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
    654         while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
    655             $next += 12 * HOUR_IN_SECONDS;
    656         }
    657         $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    658         // Add a random number of minutes, so we don't have all sites trying to update exactly on the hour
    659         $next = $next + rand( 0, 59 ) * MINUTE_IN_SECONDS;
    660         wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
    661     }
     649    if ( ( wp_next_scheduled( 'wp_maybe_auto_update' ) > ( time() + HOUR_IN_SECONDS ) ) && ! wp_installing() )
     650        wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
    662651}
    663652
Note: See TracChangeset for help on using the changeset viewer.