WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/12/2020 01:14:01 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Administration: Handle the result of Plugin_Upgrader::bulk_upgrade() for a plugin that is already at the latest version in the same way it is handled for themes.

This corrects a fragile check of the result in wp_ajax_update_plugin() that depended on the internal array pointer, and brings some consistency with wp_ajax_update_theme().

Follow-up to [37714], [48401].
See #50448.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r48375 r48445  
    44634463        wp_send_json_error( $status );
    44644464    } elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) {
    4465         $plugin_update_data = current( $result );
    44664465
    44674466        /*
    4468          * If the `update_plugins` site transient is empty (e.g. when you update
    4469          * two plugins in quick succession before the transient repopulates),
    4470          * this may be the return.
     4467         * Plugin is already at the latest version.
     4468         *
     4469         * This may also be the return value If the `update_plugins` site transient is empty,
     4470         * e.g. when you update two plugins in quick succession before the transient repopulates.
    44714471         *
    44724472         * Preferably something can be done to ensure `update_plugins` isn't empty.
    44734473         * For now, surface some sort of error here.
    44744474         */
    4475         if ( true === $plugin_update_data ) {
    4476             $status['errorMessage'] = __( 'Plugin update failed.' );
     4475        if ( true === $result[ $plugin ] ) {
     4476            $status['errorMessage'] = $upgrader->strings['up_to_date'];
    44774477            wp_send_json_error( $status );
    44784478        }
     
    44854485            $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
    44864486        }
     4487
    44874488        wp_send_json_success( $status );
    44884489    } elseif ( false === $result ) {
Note: See TracChangeset for help on using the changeset viewer.