diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index b821c0e04c..4a30934a5e 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -4462,18 +4462,18 @@ function wp_ajax_update_plugin() { $status['errorMessage'] = $skin->get_error_messages(); wp_send_json_error( $status ); } elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) { - $plugin_update_data = current( $result ); /* - * If the `update_plugins` site transient is empty (e.g. when you update - * two plugins in quick succession before the transient repopulates), - * this may be the return. + * Plugin is already at the latest version. + * + * This may also be the return value If the `update_plugins` site transient is empty, + * e.g. when you update two plugins in quick succession before the transient repopulates. * * Preferably something can be done to ensure `update_plugins` isn't empty. * For now, surface some sort of error here. */ - if ( true === $plugin_update_data ) { - $status['errorMessage'] = __( 'Plugin update failed.' ); + if ( true === $result[ $plugin ] ) { + $status['errorMessage'] = $upgrader->strings['up_to_date']; wp_send_json_error( $status ); } @@ -4484,6 +4484,7 @@ function wp_ajax_update_plugin() { /* translators: %s: Plugin version. */ $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); } + wp_send_json_success( $status ); } elseif ( false === $result ) { global $wp_filesystem; diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index cad0a613ac..22f8221e7b 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -391,8 +391,8 @@ class Plugin_Upgrader extends WP_Upgrader { unset( $past_failure_emails[ $plugin ] ); } + update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); - reset( $results ); return $results; } diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 9dfb751d12..b5364c84ce 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -500,8 +500,8 @@ class Theme_Upgrader extends WP_Upgrader { unset( $past_failure_emails[ $theme ] ); } + update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); - reset( $results ); return $results; } diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index d4244fb026..8b1cc4b5fb 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -660,7 +660,7 @@ class WP_Upgrader { * @type array $hook_extra Extra arguments to pass to the filter hooks called by * WP_Upgrader::run(). * } - * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error, + * @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error, * or false if unable to connect to the filesystem. */ public function run( $options ) { diff --git a/tests/phpunit/tests/ajax/UpdatePlugin.php b/tests/phpunit/tests/ajax/UpdatePlugin.php index c761bddd48..ffc027123e 100644 --- a/tests/phpunit/tests/ajax/UpdatePlugin.php +++ b/tests/phpunit/tests/ajax/UpdatePlugin.php @@ -157,7 +157,7 @@ class Tests_Ajax_Update_Plugin extends WP_Ajax_UnitTestCase { 'slug' => 'hello-dolly', 'plugin' => 'hello.php', 'pluginName' => 'Hello Dolly', - 'errorMessage' => 'Plugin update failed.', + 'errorMessage' => 'The plugin is at the latest version.', 'oldVersion' => 'Version 1.7.2', 'newVersion' => '', 'debug' => array( 'The plugin is at the latest version.' ),