Subramanya Sastry has submitted this change and it was merged.
Change subject: Pass in an apiURI to the WikiConfig constructor
......................................................................
Pass in an apiURI to the WikiConfig constructor
I've taken out the parsoidConfig parameter and made sure to pass in a valid
URI to the WikiConfig constructor in the useLocalConfig case.
Change-Id: Ic43067a2980f2c49fe82e39a933c8ca28fa357b4
---
M js/lib/mediawiki.ApiRequest.js
M js/lib/mediawiki.ParsoidConfig.js
M js/lib/mediawiki.WikiConfig.js
M js/lib/mediawiki.parser.environment.js
M js/tests/parserTests.js
5 files changed, 15 insertions(+), 9 deletions(-)
Approvals:
Subramanya Sastry: Verified; Looks good to me, approved
diff --git a/js/lib/mediawiki.ApiRequest.js b/js/lib/mediawiki.ApiRequest.js
index c038cbd..9361dc8 100644
--- a/js/lib/mediawiki.ApiRequest.js
+++ b/js/lib/mediawiki.ApiRequest.js
@@ -380,7 +380,7 @@
var ConfigRequest = function ( confSource, env ) {
ApiRequest.call( this, env, null );
- if ( env.conf.parsoid.useLocalConfig ) {
+ if ( !env.conf.parsoid.fetchConfig ) {
// Hack! Configured to use local configurations, probably for
// parserTests. Fetch the cached versions and use those.
// The confSource will be a filename in this case.
diff --git a/js/lib/mediawiki.ParsoidConfig.js
b/js/lib/mediawiki.ParsoidConfig.js
index e366e9d..d3bf762 100644
--- a/js/lib/mediawiki.ParsoidConfig.js
+++ b/js/lib/mediawiki.ParsoidConfig.js
@@ -50,7 +50,7 @@
ParsoidConfig.prototype.usePHPPreProcessor = true;
ParsoidConfig.prototype.defaultWiki = 'en';
ParsoidConfig.prototype.useSelser = false;
-ParsoidConfig.prototype.useLocalConfig = false;
+ParsoidConfig.prototype.fetchConfig = true;
if (typeof module === "object") {
module.exports.ParsoidConfig = ParsoidConfig;
diff --git a/js/lib/mediawiki.WikiConfig.js b/js/lib/mediawiki.WikiConfig.js
index 9ac75a2..3ceff70 100644
--- a/js/lib/mediawiki.WikiConfig.js
+++ b/js/lib/mediawiki.WikiConfig.js
@@ -9,13 +9,13 @@
Util = require( './mediawiki.Util.js' ).Util,
request = require( 'request' );
-var WikiConfig = function ( resultConf, prefix, uri, parsoidConf ) {
+var WikiConfig = function ( resultConf, prefix, uri ) {
var nsid, name, conf = this;
this.init(); // initialize hashes/arrays/etc.
conf.iwp = prefix;
- if ( uri && ( !parsoidConf || !parsoidConf.useLocalConfig ) ) {
+ if ( uri ) {
this.apiURI = uri;
}
diff --git a/js/lib/mediawiki.parser.environment.js
b/js/lib/mediawiki.parser.environment.js
index d8624e1..b6f6409 100644
--- a/js/lib/mediawiki.parser.environment.js
+++ b/js/lib/mediawiki.parser.environment.js
@@ -192,14 +192,16 @@
*/
MWParserEnvironment.prototype.switchToConfig = function ( prefix, cb ) {
// This is sometimes a URI, sometimes a prefix.
- var confSource = this.conf.parsoid.interwikiMap[prefix];
- this.conf.parsoid.apiURI = confSource ||
this.conf.parsoid.interwikiMap['en'];
+ var confSource, uri = this.conf.parsoid.interwikiMap[prefix];
+ this.conf.parsoid.apiURI = uri || this.conf.parsoid.interwikiMap['en'];
this.confCache = this.confCache || {};
this.confCache[this.conf.wiki.iwp || ''] = this.conf.wiki;
- if ( this.conf.parsoid.useLocalConfig ) {
+ if ( !this.conf.parsoid.fetchConfig ) {
// Use the name of a cache file as the source of the config.
confSource = './baseconfig/' + prefix + '.json';
+ } else {
+ confSource = uri;
}
if ( this.confCache[prefix || ''] ) {
@@ -208,8 +210,12 @@
} else {
var confRequest = new ConfigRequest( confSource, this );
confRequest.on( 'src', function ( error, resultConf ) {
+ var thisuri = confSource;
+ if ( !this.conf.parsoid.fetchConfig && uri ) {
+ thisuri = uri;
+ }
if ( error === null ) {
- this.conf.wiki = new WikiConfig( resultConf,
prefix, confSource, this.conf.parsoid );
+ this.conf.wiki = new WikiConfig( resultConf,
prefix, thisuri );
}
cb( error );
diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index 1c8d003..48c0876 100644
--- a/js/tests/parserTests.js
+++ b/js/tests/parserTests.js
@@ -1121,7 +1121,7 @@
options.fetchTemplates = false;
options.usePHPPreProcessor = false;
- options.useLocalConfig = true;
+ options.fetchConfig = false;
var parsoidConfig = new ParsoidConfig( null, options );
--
To view, visit https://gerrit.wikimedia.org/r/53390
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic43067a2980f2c49fe82e39a933c8ca28fa357b4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits