Customize: Prevent attachment deletions from silently failing in media modals opened for Media widgets.

Amends [40640].
See #32417.
Fixes #41609.


git-svn-id: https://develop.svn.wordpress.org/trunk@41248 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-08-13 06:10:11 +00:00
parent a29068cb00
commit 8b6b45c96b

View File

@ -708,10 +708,14 @@ wp.mediaWidgets = ( function( $ ) {
control.model.set( control.getModelPropsFromMediaFrame( mediaFrame ) ); control.model.set( control.getModelPropsFromMediaFrame( mediaFrame ) );
}); });
// Disable syncing of attachment changes back to server. See <https://core.trac.wordpress.org/ticket/40403>. // Disable syncing of attachment changes back to server (except for deletions). See <https://core.trac.wordpress.org/ticket/40403>.
defaultSync = wp.media.model.Attachment.prototype.sync; defaultSync = wp.media.model.Attachment.prototype.sync;
wp.media.model.Attachment.prototype.sync = function rejectedSync() { wp.media.model.Attachment.prototype.sync = function( method ) {
return $.Deferred().rejectWith( this ).promise(); if ( 'delete' === method ) {
return defaultSync.apply( this, arguments );
} else {
return $.Deferred().rejectWith( this ).promise();
}
}; };
mediaFrame.on( 'close', function onClose() { mediaFrame.on( 'close', function onClose() {
wp.media.model.Attachment.prototype.sync = defaultSync; wp.media.model.Attachment.prototype.sync = defaultSync;