WordPress.org

Make WordPress Core

Changeset 25750


Ignore:
Timestamp:
10/10/2013 01:31:22 AM (5 years ago)
Author:
dd32
Message:

In the event that an Automatic Upgrade fails, send a failure status on the next API request to indicate that it failed, and if the rollback was successful.
See #22704

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25700 r25750  
    13001300
    13011301        // In the event of an error, rollback to the previous version
    1302         if ( is_wp_error( $result ) && $parsed_args['attempt_rollback'] && $current->packages->rollback ) {
     1302        if ( is_wp_error( $result ) && $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) {
    13031303            apply_filters( 'update_feedback', $result );
    13041304            apply_filters( 'update_feedback', $this->strings['start_rollback'] );
    13051305
    1306             $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
    1307 
    1308             $result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'] );
     1306            $rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
     1307
     1308            $result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], array( 'rollback' => $rollback_result, 'update' => $result ) );
    13091309        }
    13101310        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ), $result );
     
    17271727        // Next, Process any core upgrade
    17281728        wp_version_check(); // Check for Core updates
     1729        $extra_update_stats = array();
    17291730        $core_update = find_core_auto_update();
    17301731        if ( $core_update ) {
    1731             self::upgrade( 'core', $core_update );
     1732            $start_time = time();
     1733            $core_update_result = self::upgrade( 'core', $core_update );
    17321734            delete_site_transient( 'update_core' );
     1735            $extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true;
     1736            if ( is_wp_error( $core_update_result ) && 'rollback_was_required' == $core_update_result->get_error_code() ) {
     1737                $rollback_data = $core_update_result->get_error_data();
     1738                $extra_update_stats['success'] = is_wp_error( $rollback_data['update'] ) ? $rollback_data['update']->get_error_code() : $rollback_data['update'];
     1739                $extra_update_stats['rollback'] = is_wp_error( $rollback_data['rollback'] ) ? $rollback_data['rollback']->get_error_code() : $rollback_data['rollback'];
     1740            }
     1741            $extra_update_stats['fs_method'] = $GLOBALS['wp_filesystem']->method;
     1742            $extra_update_stats['time_taken'] = ( time() - $start_time );
    17331743        }
    17341744
    17351745        // Cleanup, and check for any pending translations
    1736         wp_version_check();  // check for Core updates
     1746        wp_version_check( $extra_update_stats );  // check for Core updates
    17371747        wp_update_themes();  // Check for Theme updates
    17381748        wp_update_plugins(); // Check for Plugin updates
  • trunk/src/wp-includes/update.php

    r25699 r25750  
    1818 * @uses $wp_version Used to check against the newest WordPress version.
    1919 *
     20 * @param array $extra_stats Extra statistics to report to the WordPress.org API.
    2021 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    2122 */
    22 function wp_version_check() {
     23function wp_version_check( $extra_stats = array() ) {
    2324    if ( defined('WP_INSTALLING') )
    2425        return;
     
    4041    $timeout = 60;
    4142    $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    42     if ( $time_not_changed )
     43    if ( $time_not_changed && empty( $extra_args ) )
    4344        return false;
    4445
     
    8384        'blogs'             => $num_blogs,
    8485        'users'             => $user_count,
    85         'multisite_enabled' => $multisite_enabled
     86        'multisite_enabled' => $multisite_enabled,
    8687    );
     88
     89    if ( $extra_stats )
     90        $query = array_merge( $query, $extra_stats );
    8791
    8892    $url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
     
    543547add_action( 'admin_init', '_maybe_update_core' );
    544548add_action( 'wp_version_check', 'wp_version_check' );
    545 add_action( 'upgrader_process_complete', 'wp_version_check' );
     549add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
    546550
    547551add_action( 'load-plugins.php', 'wp_update_plugins' );
Note: See TracChangeset for help on using the changeset viewer.