MediaWiki:Gadget-morebits.js: Difference between revisions

Add hybrid changes for new API handling of af and sbl errors, see #707
imported>Amorymeltzer
(Repo at f7e03c7: replace + in Morebits.queryString (fix longstanding bug))
(Add hybrid changes for new API handling of af and sbl errors, see #707)
Line 2,621:
}
 
// errors here are only generated by extensions which hook APIEditBeforeSave within MediaWiki,
// Wikimediawhich wikisas shouldof only1.34.0-wmf.23 return(Sept spam2019) blacklistshould errors, captchas,only andencompass AbuseFiltercaptcha messages
var $editNode = $(xml).find('edit');
var blacklist = $editNode.attr('spamblacklist');
Line 2,656:
// callback from saveApi.post()
var fnSaveError = function() {
 
var errorCode = ctx.saveApi.getErrorCode();
 
Line 2,706 ⟶ 2,705:
if (errorCode === 'protectedpage') {
ctx.statusElement.error('Failed to save edit: Page is protected');
// check for absuefilter hits: disallowed or warning
} else if (errorCode.indexOf('abusefilter') === 0) {
var desc = $(ctx.saveApi.getXML()).find('abusefilter').attr('description');
if (errorCode === 'abusefilter-disallowed') {
ctx.statusElement.error('The edit was disallowed by the edit filter: "' + desc + '".');
} else if (errorCode === 'abusefilter-warning') {
ctx.statusElement.error([ 'A warning was returned by the edit filter: "', desc, '". If you wish to proceed with the edit, please carry it out again. This warning will not appear a second time.' ]);
// We should provide the user with a way to automatically retry the action if they so choose -
// I can't see how to do this without creating a UI dependency on Morebits.wiki.page though -- TTO
} else { // shouldn't happen but...
ctx.statusElement.error('The edit was disallowed by the edit filter.');
}
// check for blacklist hits
} else if (errorCode === 'spamblacklist') {
ctx.statusElement.error(ctx.saveApi.getErrorText());
} else {
ctx.statusElement.error('Failed to save edit: ' + ctx.saveApi.getErrorText());
Anonymous user