Merge "ArticleTargetSaver: Fix handling for data.result !== 'success'"

This commit is contained in:
jenkins-bot 2019-11-19 21:18:01 +00:00 committed by Gerrit Code Review
commit 924e579c19
2 changed files with 10 additions and 7 deletions

View file

@ -1545,11 +1545,14 @@ ve.init.mw.ArticleTarget.prototype.getWikitextDiffPromise = function ( doc ) {
oldid: this.revid,
etag: this.etag
}, 'diff' ).then( function ( data ) {
if ( data.result === 'nochanges' ) {
return data.diff;
}, function ( code, response ) {
// ArticleTargetSaver treats this as an error, this is silly
if ( response.visualeditoredit && response.visualeditoredit.result === 'nochanges' ) {
target.emit( 'noChanges' );
return null;
}
return data.diff;
return ve.createDeferred().reject( code, response ).promise();
} );
this.wikitextDiffPromise
.done( this.emit.bind( this, 'showChanges' ) )

View file

@ -256,11 +256,11 @@
html: 'Invalid response from server'
};
} else if ( data.result !== 'success' ) {
// Note, this could be any of db failure, hookabort, badtoken or even a captcha
error = {
code: 'failure',
html: 'Save failure: ' + mw.html.escape( data.result )
};
// This can only happen when:
// * viewing a diff with no changes (`data.result === 'nochanges'`)
// * saving an edit and getting a captcha (`data.result === 'error'`)
// It's a silly special case...
return $.Deferred().reject( 'no-error-no-success', response ).promise();
} else {
// paction specific errors
switch ( data.paction ) {