Automatic updates: Include error data in the follow-up API request.

props dd32.
see #22704.

Built from https://develop.svn.wordpress.org/trunk@25781


git-svn-id: http://core.svn.wordpress.org/trunk@25694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-14 23:33:10 +00:00
parent 9b56d4d11f
commit cdede88a23
2 changed files with 10 additions and 4 deletions

View File

@ -1747,12 +1747,16 @@ class WP_Automatic_Upgrader {
$core_update_result = self::upgrade( 'core', $core_update );
delete_site_transient( 'update_core' );
$extra_update_stats['success'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_code() : true;
$extra_update_stats['error_data'] = is_wp_error( $core_update_result ) ? $core_update_result->get_error_data() : '';
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['error_data'] = is_wp_error( $rollback_data['update'] ) ? $rollback_data['update']->get_error_data() : '';
$extra_update_stats['rollback'] = is_wp_error( $rollback_data['rollback'] ) ? $rollback_data['rollback']->get_error_code() : true; // If it's not a WP_Error, the rollback was successful.
$extra_update_stats['rollback_data'] = is_wp_error( $rollback_data['rollback'] ) ? $rollback_data['rollback']->get_error_data() : '';
}
$extra_update_stats['fs_method'] = $GLOBALS['wp_filesystem']->method;
$extra_update_stats['fs_method_forced'] = defined( 'FS_METHOD' ) || has_filter( 'fs_method' );
$extra_update_stats['time_taken'] = ( time() - $start_time );
$extra_update_stats['attempted'] = $core_update->version;
}

View File

@ -86,8 +86,12 @@ function wp_version_check( $extra_stats = array() ) {
'multisite_enabled' => $multisite_enabled,
);
$post_body = array(
'translations' => json_encode( $translations ),
);
if ( $extra_stats )
$query = array_merge( $query, $extra_stats );
$post_body = array_merge( $post_body, $extra_stats );
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
if ( wp_http_supports( array( 'ssl' ) ) )
@ -100,9 +104,7 @@ function wp_version_check( $extra_stats = array() ) {
'wp_install' => $wp_install,
'wp_blog' => home_url( '/' )
),
'body' => array(
'translations' => json_encode( $translations ),
),
'body' => $post_body,
);
$response = wp_remote_post( $url, $options );