Make WordPress Core

Ticket #27772: 27772.diff

File 27772.diff, 2.0 KB (added by dd32, 11 years ago)
  • src/wp-includes/update.php

     
    141141                        else
    142142                                $offer[ $offer_key ] = esc_html( $value );
    143143                }
    144144                $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale',
    145145                        'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) );
    146146        }
    147147
    148148        $updates = new stdClass();
    149149        $updates->updates = $offers;
    150150        $updates->last_checked = time();
    151151        $updates->version_checked = $wp_version;
    152152
    153153        if ( isset( $body['translations'] ) )
    154154                $updates->translations = $body['translations'];
    155155
    156         set_site_transient( 'update_core',  $updates);
     156        set_site_transient( 'update_core', $updates );
     157
     158// Testing only, causes an update cron task to be run every 90seconds
     159$body['ttl'] = 90;
     160
     161        if ( !empty( $body['ttl'] ) ) {
     162                $ttl = (int) $body['ttl'];
     163                if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) {
     164                        // Queue an event to re-run the update check in $ttl seconds
     165                        wp_schedule_single_event( time() + $ttl, 'wp_version_check' );
     166                }
     167        }
     168
     169        // Trigger a Background Updates check if running non-interactively, and we weren't called from the update handler
     170        if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) {
     171                do_action( 'wp_maybe_auto_update' );
     172        }
    157173}
    158174
    159175/**
    160176 * Check plugin versions against the latest versions hosted on WordPress.org.
    161177 *
    162178 * The WordPress version, PHP version, and Locale is sent along with a list of
    163179 * all plugins installed. Checks against the WordPress server at
    164180 * api.wordpress.org. Will only check if WordPress isn't installing.
    165181 *
    166182 * @since 2.3.0
    167183 * @uses $wp_version Used to notify the WordPress version.
    168184 *
    169185 * @param array $extra_stats Extra statistics to report to the WordPress.org API.
    170186 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    171187 */