Make WordPress Core

Changeset 56009


Ignore:
Timestamp:
06/24/2023 03:58:37 AM (11 months ago)
Author:
audrasjb
Message:

Upgrade/Install: Prevent users from sending multiple bulk plugin updates.

This changeset improves update.js by adding is-enqueued class to enqueued plugin updates to prevent users from asking for several updates for the same
plugin at the same time, which previously resulted to …an interesting experience.

Props bitnissen, swissspidy, MarcGuay, xkon, afercia, swissspidy, bookdude13, simonemanfre, vasilism, costdev, zunaid321.
Fixes #40966.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/updates.js

    r55359 r56009  
    516516        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
    517517            $pluginRow     = $( 'tr[data-plugin="' + response.plugin + '"]' )
    518                 .removeClass( 'update' )
     518                .removeClass( 'update is-enqueued' )
    519519                .addClass( 'updated' );
    520520            $updateMessage = $pluginRow.find( '.update-message' )
     
    586586
    587587        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
     588            $pluginRow = $( 'tr[data-plugin="' + response.plugin + '"]' ).removeClass( 'is-enqueued' );
     589
    588590            if ( response.plugin ) {
    589591                $message = $( 'tr[data-plugin="' + response.plugin + '"]' ).find( '.update-message' );
     
    24692471                }
    24702472
     2473                // Don't add items to the update queue again, even if the user clicks the update button several times.
     2474                if ( 'update-selected' === bulkAction && $itemRow.hasClass( 'is-enqueued' ) ) {
     2475                    return;
     2476                }
     2477
     2478                $itemRow.addClass( 'is-enqueued' )
     2479
    24712480                // Add it to the queue.
    24722481                wp.updates.queue.push( {
Note: See TracChangeset for help on using the changeset viewer.