WordPress.org

Make WordPress Core

Changeset 28129


Ignore:
Timestamp:
04/15/2014 02:22:07 AM (4 years ago)
Author:
nacin
Message:

Add a TTL to core update checks to allow us to narrow the 12-hour update window.

props dd32.
fixes #27772.

File:
1 edited

Legend:

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

    r27928 r28129  
    154154        $updates->translations = $body['translations'];
    155155
    156     set_site_transient( 'update_core',  $updates);
     156    set_site_transient( 'update_core', $updates );
     157
     158    if ( ! empty( $body['ttl'] ) ) {
     159        $ttl = (int) $body['ttl'];
     160        if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
     161            // Queue an event to re-run the update check in $ttl seconds.
     162            wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
     163        }
     164    }
     165
     166    // Trigger a background updates check if running non-interactively, and we weren't called from the update handler.
     167    if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
     168        do_action( 'wp_maybe_auto_update' );
     169    }
    157170}
    158171
     
    204217            break;
    205218        default :
    206             $timeout = 12 * HOUR_IN_SECONDS;
     219            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     220                $timeout = 0;
     221            } else {
     222                $timeout = 12 * HOUR_IN_SECONDS;
     223            }
    207224    }
    208225
     
    350367            break;
    351368        default :
    352             $timeout = 12 * HOUR_IN_SECONDS;
     369            if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
     370                $timeout = 0;
     371            } else {
     372                $timeout = 12 * HOUR_IN_SECONDS;
     373            }
    353374    }
    354375
Note: See TracChangeset for help on using the changeset viewer.