Make WordPress Core

Ticket #32086: 32086.patch

File 32086.patch, 2.0 KB (added by mordauk, 8 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    29152915        $result = $upgrader->bulk_upgrade( array( $plugin ) );
    29162916
    29172917        if ( is_array( $result ) ) {
    2918                 $plugin_update_data = current( $result );
    29192918
    2920                 /*
    2921                  * If the `update_plugins` site transient is empty (e.g. when you update
    2922                  * two plugins in quick succession before the transient repopulates),
    2923                  * this may be the return.
    2924                  *
    2925                  * Preferably something can be done to ensure `update_plugins` isn't empty.
    2926                  * For now, surface some sort of error here.
    2927                  */
    2928                 if ( $plugin_update_data === true ) {
     2919                if( is_wp_error( $result[ $plugin ] ) ) {
     2920
     2921                        $status['error'] = $result[ $plugin ]->get_error_message();
    29292922                        wp_send_json_error( $status );
    2930                 }
    29312923
    2932                 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
     2924                } else {
    29332925
    2934                 if ( $plugin_data['Version'] ) {
    2935                         $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
     2926                        $plugin_update_data = current( $result );
     2927
     2928                        /*
     2929                         * If the `update_plugins` site transient is empty (e.g. when you update
     2930                         * two plugins in quick succession before the transient repopulates),
     2931                         * this may be the return.
     2932                         *
     2933                         * Preferably something can be done to ensure `update_plugins` isn't empty.
     2934                         * For now, surface some sort of error here.
     2935                         */
     2936                        if ( $plugin_update_data === true ) {
     2937                                wp_send_json_error( $status );
     2938                        }
     2939
     2940                        $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
     2941
     2942                        if ( $plugin_data['Version'] ) {
     2943                                $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
     2944                        }
     2945                        $status['test'] = $result[ $plugin ];
     2946                        wp_send_json_success( $status );
     2947
    29362948                }
    29372949
    2938                 wp_send_json_success( $status );
    29392950        } else if ( is_wp_error( $result ) ) {
    29402951                $status['error'] = $result->get_error_message();
    29412952                wp_send_json_error( $status );