Skip to content

Commit

Permalink
Don't use the stored uri from parsoid config
Browse files Browse the repository at this point in the history
 * The parsoid config is used across requests and storing anything there
   is setting yourself up for race conditions.

 * This was causing major corruption on wiki.

 * The refactor in 915ea3f went from
   using a bound copy of the uri to that stored on the parsoid config,
   causing some concurrent requests to use the wrong API.

Change-Id: Ia2244b9737fee1563ca3a33ba3b8683862b39d24
  • Loading branch information
arlolra committed Apr 25, 2015
1 parent 1120330 commit bcea0ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/mediawiki.parser.environment.js
Expand Up @@ -278,11 +278,11 @@ MWParserEnvironment.prototype.switchToConfig = function(prefix, cb) {
var nothingToDo = {}; // unique marker value
var parsoid = env.conf.parsoid;

var getConfigPromise;
var getConfigPromise, uri;
if (!prefix) {
getConfigPromise = Promise.reject(new Error('Wiki prefix not provided'));
} else {
var uri = parsoid.interwikiMap.get(prefix);
uri = parsoid.interwikiMap.get(prefix);
if (!uri) {
// SSS: Ugh! Looks like parser tests use a prefix
// that is not part of the interwikiMap -- so we
Expand Down Expand Up @@ -318,7 +318,7 @@ MWParserEnvironment.prototype.switchToConfig = function(prefix, cb) {

return getConfigPromise.then(function(resultConf) {
if (resultConf === nothingToDo) { return; }
env.conf.wiki = new WikiConfig(env, resultConf, prefix, parsoid.apiURI,
env.conf.wiki = new WikiConfig(env, resultConf, prefix, uri,
env.getAPIProxy(prefix));
env.confCache[prefix] = env.conf.wiki;
}).nodify(cb);
Expand Down

0 comments on commit bcea0ab

Please sign in to comment.