jenkins-bot has submitted this change and it was merged. Change subject: ext.translate.editor: Improve save failure detection ......................................................................
ext.translate.editor: Improve save failure detection mw.API() edit doesn't always return fail promises for actual save failures. The proper way to check for success is checking for the presence of "Success" in the API result. As we didn't check for this previously, this caused some save failures to be reported as successful to the user. Also now specific messages are shown for AbuseFilter and SpamBlacklist save failures. TODO: Use i18n in "unknown error" message. Bug: T142291 Bug: T61715 Change-Id: I7533d6aaee017aeb11f4c48658a35550afc94946 --- M Resources.php M resources/js/ext.translate.editor.js 2 files changed, 19 insertions(+), 4 deletions(-) Approvals: Nikerabbit: Checked; Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 63a7b9e..d785d74 100644 --- a/Resources.php +++ b/Resources.php @@ -111,6 +111,7 @@ 'tux-status-unsaved', 'tux-warnings-hide', 'tux-warnings-more', + 'spamprotectiontext', ), 'position' => 'top', ) + $resourcePaths; diff --git a/resources/js/ext.translate.editor.js b/resources/js/ext.translate.editor.js index b8d4668..24e3404 100644 --- a/resources/js/ext.translate.editor.js +++ b/resources/js/ext.translate.editor.js @@ -210,10 +210,24 @@ translateEditor.message.title, translation, editSummary - ).done( function () { - // Update the translation - translateEditor.message.translation = translation; - translateEditor.onSaveSuccess(); + ).done( function ( response, xhr ) { + var editResp = response.edit; + if ( editResp.result === 'Success' ) { + translateEditor.message.translation = translation; + translateEditor.onSaveSuccess(); + // Handle errors + } else if ( editResp.spamblacklist ) { + // @todo Show exactly which blacklisted URL triggered it + translateEditor.onSaveFail( mw.msg( 'spamprotectiontext' ) ); + } else if ( editResp.info && + editResp.info.indexOf( 'Hit AbuseFilter:' ) === 0 && + editResp.warning + ) { + translateEditor.onSaveFail( editResp.warning ); + } else { + translateEditor.onSaveFail( 'Unknown error occured.' ); + mw.log( response, xhr ); + } } ).fail( function ( errorCode, response ) { translateEditor.onSaveFail( response.error && response.error.info || 'Unknown error' ); if ( errorCode === 'assertuserfailed' ) { -- To view, visit https://gerrit.wikimedia.org/r/303430 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7533d6aaee017aeb11f4c48658a35550afc94946 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Glaisher <glaisher.w...@gmail.com> Gerrit-Reviewer: Glaisher <glaisher.w...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits