Make WordPress Core

Changeset 33302


Ignore:
Timestamp:
07/17/2015 03:58:23 AM (9 years ago)
Author:
dd32
Message:

Updates: Correctly identify more failed update cases.
This checks for a WP_Error being raised during an individual update, in addition to just the bootstrap error cases.
When a error occurs during the connection phase, pass the error message back as the ajax failure message.

Merges [32571] & [32778] to the 4.2 branch

See #32473, #32435

Location:
branches/4.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

  • branches/4.2/src/wp-admin/includes/ajax-actions.php

    r33301 r33302  
    28842884 */
    28852885function wp_ajax_update_plugin() {
     2886    global $wp_filesystem;
     2887
    28862888    $plugin = urldecode( $_POST['plugin'] );
    28872889
     
    29102912    wp_update_plugins();
    29112913
    2912     $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
     2914    $skin = new Automatic_Upgrader_Skin();
     2915    $upgrader = new Plugin_Upgrader( $skin );
    29132916    $result = $upgrader->bulk_upgrade( array( $plugin ) );
    29142917
    2915     if ( is_array( $result ) ) {
     2918    if ( is_array( $result ) && empty( $result[$plugin] ) && is_wp_error( $skin->result ) ) {
     2919        $result = $skin->result;
     2920    }
     2921
     2922    if ( is_array( $result ) && !empty( $result[ $plugin ] ) ) {
    29162923        $plugin_update_data = current( $result );
    29172924
     
    29392946        $status['error'] = $result->get_error_message();
    29402947        wp_send_json_error( $status );
    2941     } else if ( is_bool( $result ) && ! $result ) {
     2948
     2949    } else if ( is_bool( $result ) && ! $result ) {
    29422950        $status['errorCode'] = 'unable_to_connect_to_filesystem';
    29432951        $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
     2952
     2953        // Pass through the error from WP_Filesystem if one was raised
     2954        if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
     2955            $status['error'] = $wp_filesystem->errors->get_error_message();
     2956        }
     2957
    29442958        wp_send_json_error( $status );
     2959
    29452960    }
    29462961}
Note: See TracChangeset for help on using the changeset viewer.