Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/61034


Change subject: Make all API requests go through ApiRequest.request().
......................................................................

Make all API requests go through ApiRequest.request().

When mocking, caching, or just debugging, it's helpful to be able to watch
all network API requests.  These all now go through ApiRequest.request(),
making it easier to set breakpoints and/or add debugging code.

Change-Id: Ia1e677fb91190610dbd325641953b4c276fef8ff
---
M js/lib/mediawiki.ApiRequest.js
1 file changed, 12 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/34/61034/1

diff --git a/js/lib/mediawiki.ApiRequest.js b/js/lib/mediawiki.ApiRequest.js
index b2ce759..4feea41 100644
--- a/js/lib/mediawiki.ApiRequest.js
+++ b/js/lib/mediawiki.ApiRequest.js
@@ -69,6 +69,12 @@
 // Inherit from EventEmitter
 util.inherits(ApiRequest, events.EventEmitter);
 
+ApiRequest.prototype.request = function( options, callback ) {
+       // this is a good place to put debugging statements
+       // if you want to watch network requests.
+       return request( options, callback );
+};
+
 /**
  * @method
  * @private
@@ -117,7 +123,7 @@
                        this.env.tp( 'Retrying ' + this.reqType + ' request for 
' + this.title + ', ' +
                                        this.retries + ' remaining' );
                        // retry
-                       request( this.requestOptions, 
this._requestCB.bind(this) );
+                       this.request( this.requestOptions, 
this._requestCB.bind(this) );
                        return;
                } else {
                        var dnee = new DoesNotExistError( this.reqType + ' 
failure for ' + this.title );
@@ -206,7 +212,7 @@
        };
 
        // Start the request
-       request( this.requestOptions, this._requestCB.bind(this) );
+       this.request( this.requestOptions, this._requestCB.bind(this) );
 }
 
 // Inherit from ApiRequest
@@ -289,7 +295,7 @@
                
//'?format=json&action=query&prop=revisions&rvprop=content&titles=' + title;
                this.requestOptions.url = url;
                this.title = title;
-               request( this.requestOptions, this._requestCB.bind(this) );
+               this.request( this.requestOptions, this._requestCB.bind(this) );
                return;
        }
 
@@ -347,7 +353,7 @@
        };
 
        // Start the request
-       request( this.requestOptions, this._requestCB.bind(this) );
+       this.request( this.requestOptions, this._requestCB.bind(this) );
 }
 
 
@@ -428,7 +434,7 @@
        };
 
        // Start the request
-       request( this.requestOptions, this._requestCB.bind(this) );
+       this.request( this.requestOptions, this._requestCB.bind(this) );
 }
 
 // Inherit from ApiRequest
@@ -524,7 +530,7 @@
                }
        };
 
-       request( this.requestOptions, this._requestCB.bind( this ) );
+       this.request( this.requestOptions, this._requestCB.bind( this ) );
 };
 
 util.inherits( ConfigRequest, ApiRequest );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1e677fb91190610dbd325641953b4c276fef8ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

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

Reply via email to