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 git-svn-id: https://develop.svn.wordpress.org/trunk@25750 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6c808113fe
commit
e03279e8b0
@ -1299,13 +1299,13 @@ class Core_Upgrader extends WP_Upgrader {
|
|||||||
$result = update_core( $working_dir, $wp_dir );
|
$result = update_core( $working_dir, $wp_dir );
|
||||||
|
|
||||||
// In the event of an error, rollback to the previous version
|
// In the event of an error, rollback to the previous version
|
||||||
if ( is_wp_error( $result ) && $parsed_args['attempt_rollback'] && $current->packages->rollback ) {
|
if ( is_wp_error( $result ) && $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) {
|
||||||
apply_filters( 'update_feedback', $result );
|
apply_filters( 'update_feedback', $result );
|
||||||
apply_filters( 'update_feedback', $this->strings['start_rollback'] );
|
apply_filters( 'update_feedback', $this->strings['start_rollback'] );
|
||||||
|
|
||||||
$this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
|
$rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
|
||||||
|
|
||||||
$result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'] );
|
$result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], array( 'rollback' => $rollback_result, 'update' => $result ) );
|
||||||
}
|
}
|
||||||
do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ), $result );
|
do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ), $result );
|
||||||
return $result;
|
return $result;
|
||||||
@ -1726,14 +1726,24 @@ class WP_Automatic_Upgrader {
|
|||||||
|
|
||||||
// Next, Process any core upgrade
|
// Next, Process any core upgrade
|
||||||
wp_version_check(); // Check for Core updates
|
wp_version_check(); // Check for Core updates
|
||||||
|
$extra_update_stats = array();
|
||||||
$core_update = find_core_auto_update();
|
$core_update = find_core_auto_update();
|
||||||
if ( $core_update ) {
|
if ( $core_update ) {
|
||||||
self::upgrade( 'core', $core_update );
|
$start_time = time();
|
||||||
|
$core_update_result = self::upgrade( 'core', $core_update );
|
||||||
delete_site_transient( 'update_core' );
|
delete_site_transient( 'update_core' );
|
||||||
|
$extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true;
|
||||||
|
if ( is_wp_error( $core_update_result ) && 'rollback_was_required' == $core_update_result->get_error_code() ) {
|
||||||
|
$rollback_data = $core_update_result->get_error_data();
|
||||||
|
$extra_update_stats['success'] = is_wp_error( $rollback_data['update'] ) ? $rollback_data['update']->get_error_code() : $rollback_data['update'];
|
||||||
|
$extra_update_stats['rollback'] = is_wp_error( $rollback_data['rollback'] ) ? $rollback_data['rollback']->get_error_code() : $rollback_data['rollback'];
|
||||||
|
}
|
||||||
|
$extra_update_stats['fs_method'] = $GLOBALS['wp_filesystem']->method;
|
||||||
|
$extra_update_stats['time_taken'] = ( time() - $start_time );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup, and check for any pending translations
|
// Cleanup, and check for any pending translations
|
||||||
wp_version_check(); // check for Core updates
|
wp_version_check( $extra_update_stats ); // check for Core updates
|
||||||
wp_update_themes(); // Check for Theme updates
|
wp_update_themes(); // Check for Theme updates
|
||||||
wp_update_plugins(); // Check for Plugin updates
|
wp_update_plugins(); // Check for Plugin updates
|
||||||
|
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
* @uses $wp_version Used to check against the newest WordPress version.
|
* @uses $wp_version Used to check against the newest WordPress version.
|
||||||
*
|
*
|
||||||
|
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
|
||||||
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
* @return mixed Returns null if update is unsupported. Returns false if check is too soon.
|
||||||
*/
|
*/
|
||||||
function wp_version_check() {
|
function wp_version_check( $extra_stats = array() ) {
|
||||||
if ( defined('WP_INSTALLING') )
|
if ( defined('WP_INSTALLING') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ function wp_version_check() {
|
|||||||
// Wait 60 seconds between multiple version check requests
|
// Wait 60 seconds between multiple version check requests
|
||||||
$timeout = 60;
|
$timeout = 60;
|
||||||
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
|
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
|
||||||
if ( $time_not_changed )
|
if ( $time_not_changed && empty( $extra_args ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$locale = get_locale();
|
$locale = get_locale();
|
||||||
@ -82,9 +83,12 @@ function wp_version_check() {
|
|||||||
'local_package' => isset( $wp_local_package ) ? $wp_local_package : '',
|
'local_package' => isset( $wp_local_package ) ? $wp_local_package : '',
|
||||||
'blogs' => $num_blogs,
|
'blogs' => $num_blogs,
|
||||||
'users' => $user_count,
|
'users' => $user_count,
|
||||||
'multisite_enabled' => $multisite_enabled
|
'multisite_enabled' => $multisite_enabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( $extra_stats )
|
||||||
|
$query = array_merge( $query, $extra_stats );
|
||||||
|
|
||||||
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
|
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
|
||||||
if ( wp_http_supports( array( 'ssl' ) ) )
|
if ( wp_http_supports( array( 'ssl' ) ) )
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$url = set_url_scheme( $url, 'https' );
|
||||||
@ -542,7 +546,7 @@ if ( ( ! is_main_site() && ! is_network_admin() ) || ( defined( 'DOING_AJAX' ) &
|
|||||||
|
|
||||||
add_action( 'admin_init', '_maybe_update_core' );
|
add_action( 'admin_init', '_maybe_update_core' );
|
||||||
add_action( 'wp_version_check', 'wp_version_check' );
|
add_action( 'wp_version_check', 'wp_version_check' );
|
||||||
add_action( 'upgrader_process_complete', 'wp_version_check' );
|
add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
|
||||||
|
|
||||||
add_action( 'load-plugins.php', 'wp_update_plugins' );
|
add_action( 'load-plugins.php', 'wp_update_plugins' );
|
||||||
add_action( 'load-update.php', 'wp_update_plugins' );
|
add_action( 'load-update.php', 'wp_update_plugins' );
|
||||||
|
Loading…
Reference in New Issue
Block a user