WordPress.org

Make WordPress Core

Changeset 29755


Ignore:
Timestamp:
09/21/2014 06:51:41 PM (6 years ago)
Author:
wonderboymusic
Message:

Media Grid:

  • In Bulk Edit mode, don't attempt to delete or trash an attachment that doesn't have a delete nonce. The subsequent _requery() will then properly display the attachment still present in the library.
  • Remove all updated models from the selection at the same time to avoid async race conditions. The selection is reset when the grid's select mode is deactivated, but this allows this view instance to be more portable.

This fix allows users to set caps on individual attachments without confusing the grid's library. This issue was present for bulk actions in general, had nothing to do with MEDIA_TRASH specifically.

Fixes #29597.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-views.js

    r29743 r29755  
    60306030                    priority: -60,
    60316031                    click: function() {
    6032                         var model, changed = [], self = this,
     6032                        var changed = [], removed = [], self = this,
    60336033                            selection = this.controller.state().get( 'selection' ),
    60346034                            library = this.controller.state().get( 'library' );
     
    60496049                        }
    60506050
    6051                         while ( selection.length > 0 ) {
    6052                             model = selection.at( 0 );
     6051                        selection.each( function( model ) {
     6052                            if ( ! model.get( 'nonces' )['delete'] ) {
     6053                                removed.push( model );
     6054                                return;
     6055                            }
     6056
    60536057                            if ( media.view.settings.mediaTrash && 'trash' === model.get( 'status' ) ) {
    60546058                                model.set( 'status', 'inherit' );
    60556059                                changed.push( model.save() );
    6056                                 selection.remove( model );
     6060                                removed.push( model );
    60576061                            } else if ( media.view.settings.mediaTrash ) {
    60586062                                model.set( 'status', 'trash' );
    60596063                                changed.push( model.save() );
    6060                                 selection.remove( model );
     6064                                removed.push( model );
    60616065                            } else {
    60626066                                model.destroy();
    60636067                            }
    6064                         }
     6068                        } );
    60656069
    60666070                        if ( changed.length ) {
     6071                            selection.remove( removed );
     6072
    60676073                            $.when.apply( null, changed ).then( function() {
    60686074                                library._requery( true );
Note: See TracChangeset for help on using the changeset viewer.