jenkins-bot has submitted this change and it was merged.

Change subject: mw.ViewPageTarget: Swap captcha and badtoken logic in 
onSaveError
......................................................................


mw.ViewPageTarget: Swap captcha and badtoken logic in onSaveError

This way if both are the case, the user (or VE, if possible)
will deal with badtoken first instead of potentially having to
solve the captcha twice (as each handling of the error does - and
should - end with an early return).

Change-Id: I9e4264a7001ffa9654bfab02cc955aa36ff5b6aa
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
1 file changed, 33 insertions(+), 34 deletions(-)

Approvals:
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index c26db5b..1ede8fc 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -453,40 +453,6 @@
                return;
        }
 
-       // Handle captcha
-       // Captcha "errors" usually aren't errors. We simply don't know about 
them ahead of time,
-       // so we save once, then (if required) we get an error with a captcha 
back and try again after
-       // the user solved the captcha.
-       // TODO: ConfirmEdit API is horrible, there is no reliable way to know 
whether it is a "math",
-       // "question" or "fancy" type of captcha. They all expose differently 
named properties in the
-       // API for different things in the UI. At this point we only support 
the FancyCaptha which we
-       // very intuitively detect by the presence of a "url" property.
-       editApi = data && data.visualeditoredit && data.visualeditoredit.edit;
-       if ( editApi && editApi.captcha && editApi.captcha.url ) {
-               this.captcha = {
-                       input: new ve.ui.TextInputWidget(),
-                       id: editApi.captcha.id
-               };
-               this.showMessage(
-                       'api-save-error',
-                       $( '<div>').append(
-                               // msg: simplecaptcha-edit, fancycaptcha-edit, 
..
-                               $( '<p>' ).append(
-                                       $( '<strong>' ).text( mw.msg( 
'captcha-label' ) ),
-                                       document.createTextNode( mw.msg( 
'colon-separator' ) ),
-                                       $( $.parseHTML( mw.message( 
'fancycaptcha-edit' ).parse() ) )
-                                               .filter( 'a' ).attr( 'target', 
'_blank ' ).end()
-                               ),
-                               $( '<img>' ).attr( 'src', editApi.captcha.url ),
-                               this.captcha.input.$
-                       ),
-                       {
-                               wrap: false
-                       }
-               );
-               return;
-       }
-
        // Handle token errors
        if ( data.error && data.error.code === 'badtoken' ) {
                api = new mw.Api();
@@ -577,6 +543,39 @@
                return;
        }
 
+       // Handle captcha
+       // Captcha "errors" usually aren't errors. We simply don't know about 
them ahead of time,
+       // so we save once, then (if required) we get an error with a captcha 
back and try again after
+       // the user solved the captcha.
+       // TODO: ConfirmEdit API is horrible, there is no reliable way to know 
whether it is a "math",
+       // "question" or "fancy" type of captcha. They all expose differently 
named properties in the
+       // API for different things in the UI. At this point we only support 
the FancyCaptha which we
+       // very intuitively detect by the presence of a "url" property.
+       editApi = data && data.visualeditoredit && data.visualeditoredit.edit;
+       if ( editApi && editApi.captcha && editApi.captcha.url ) {
+               this.captcha = {
+                       input: new ve.ui.TextInputWidget(),
+                       id: editApi.captcha.id
+               };
+               this.showMessage(
+                       'api-save-error',
+                       $( '<div>').append(
+                               // msg: simplecaptcha-edit, fancycaptcha-edit, 
..
+                               $( '<p>' ).append(
+                                       $( '<strong>' ).text( mw.msg( 
'captcha-label' ) ),
+                                       document.createTextNode( mw.msg( 
'colon-separator' ) ),
+                                       $( $.parseHTML( mw.message( 
'fancycaptcha-edit' ).parse() ) )
+                                               .filter( 'a' ).attr( 'target', 
'_blank ' ).end()
+                               ),
+                               $( '<img>' ).attr( 'src', editApi.captcha.url ),
+                               this.captcha.input.$
+                       ),
+                       {
+                               wrap: false
+                       }
+               );
+               return;
+       }
 
        // Handle (other) unknown and/or unrecoverable errors
        this.showMessage(

-- 
To view, visit https://gerrit.wikimedia.org/r/73963
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9e4264a7001ffa9654bfab02cc955aa36ff5b6aa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to