From 5a33c205159ca87090312f08c7cb071dd2b3cdc0 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 15 Jun 2015 03:31:40 +0000 Subject: [PATCH] Updates: When a error occurs during the connection phase, pass the error message back as the ajax failure message. See #32435 git-svn-id: https://develop.svn.wordpress.org/trunk@32778 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index f44b4f2bb4..f183d0cb01 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -2937,6 +2937,8 @@ function wp_ajax_destroy_sessions() { * @see Plugin_Upgrader */ function wp_ajax_update_plugin() { + global $wp_filesystem; + $plugin = urldecode( $_POST['plugin'] ); $status = array( @@ -3000,10 +3002,18 @@ function wp_ajax_update_plugin() { } else if ( is_wp_error( $result ) ) { $status['error'] = $result->get_error_message(); wp_send_json_error( $status ); - } else if ( is_bool( $result ) && ! $result ) { + + } else if ( is_bool( $result ) && ! $result ) { $status['errorCode'] = 'unable_to_connect_to_filesystem'; $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised + if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['error'] = $wp_filesystem->errors->get_error_message(); + } + wp_send_json_error( $status ); + } }