Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/173102
Change subject: (Bug 50121) Only return 404 page does not exist
......................................................................
(Bug 50121) Only return 404 page does not exist
* Distinguishes API request failures.
Change-Id: I609de747b80709fccdaf57df66ec5dafcf75ab08
---
M lib/mediawiki.ApiRequest.js
1 file changed, 16 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/02/173102/1
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index b0229d6..7be6ac4 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -73,7 +73,7 @@
* @param {MWParserEnvironment} env
* @param {string} title The title of the page we should fetch from the API
*/
-function ApiRequest ( env, title ) {
+function ApiRequest( env, title ) {
// call the EventEmitter constructor
events.EventEmitter.call(this);
@@ -125,7 +125,7 @@
try {
nextListener.call( self, error || null, src,
'text/x-mediawiki' );
} catch(e) {
- self.env.log("fatal", e);
+ return self.env.log("fatal", e);
}
}
if ( listeners.length ) {
@@ -160,7 +160,7 @@
this.request( this.requestOptions,
this._requestCB.bind(this) );
return;
} else {
- var dnee = new DoesNotExistError( this.reqType + '
failure for '
+ var dnee = new Error( this.reqType + ' failure for '
+
JSON.stringify(this.queueKey.substr(0, 80)) + ': ' + error );
this._handleBody( dnee, '{}' );
}
@@ -172,7 +172,7 @@
} else {
this.env.log("warning", "non-200 response:",
response.statusCode, body);
}
- error = new DoesNotExistError( this.reqType + ' failure for '
+ error = new Error( this.reqType + ' failure for '
+
JSON.stringify(this.queueKey.substr(0, 20)) + ': ' + response.statusCode );
this._handleBody( error, '{}' );
}
@@ -428,7 +428,12 @@
var src = '';
try {
src = data.expandtemplates.wikitext;
+ } catch ( e2 ) {
+ error = new DoesNotExistError( 'Did not find page revisions in
the returned body for ' +
+ this.title + e2 );
+ }
+ if ( !error ) {
//console.warn( 'Page ' + title + ': got ' + src );
this.env.tp( 'Expanded ', this.text, src );
@@ -447,9 +452,6 @@
// Add the source to the cache
this.env.pageCache[this.text] = src;
- } catch ( e2 ) {
- error = new DoesNotExistError( 'Did not find page revisions in
the returned body for ' +
- this.title + e2 );
}
//console.log( this.listeners('src') );
@@ -535,11 +537,18 @@
try {
// Strip paragraph wrapper from the html
parsedHtml = data.parse.text['*'];
+ } catch ( e2 ) {
+ error = new DoesNotExistError( 'Could not expand extension
content for ' +
+ this.title + e2 );
+ }
+
+ if ( !error ) {
// Strip two trailing newlines that action=parse adds after any
// extension output
parsedHtml = parsedHtml.replace(/\n\n$/, '');
// Also strip a paragraph wrapper, if any
parsedHtml = parsedHtml.replace(/(^<p>)|(<\/p>$)/g, '');
+
this.env.tp( 'Expanded ', this.text, parsedHtml );
// Add the modules to the page data
@@ -590,9 +599,6 @@
// Add the source to the cache
this.env.pageCache[this.text] = parsedHtml;
- } catch ( e2 ) {
- error = new DoesNotExistError( 'Could not expand extension
content for ' +
- this.title + e2 );
}
//console.log( this.listeners('parsedHtml') );
--
To view, visit https://gerrit.wikimedia.org/r/173102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I609de747b80709fccdaf57df66ec5dafcf75ab08
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits