Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177270
Change subject: Fix v2 config clobbering
......................................................................
Fix v2 config clobbering
* When pagebundle is set in v2 of the api, it altered a parsoid config
that was shared across requests. Here we copy that setting to the
environment where it's safe to be manipulated.
Change-Id: Ifa2d36accb20c8a5218f465a625184d12ba80a44
---
M api/routes.js
M lib/dom.cleanup.js
M lib/mediawiki.DOMPostProcessor.js
M lib/mediawiki.parser.environment.js
4 files changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/70/177270/1
diff --git a/api/routes.js b/api/routes.js
index 3581a62..86293d3 100644
--- a/api/routes.js
+++ b/api/routes.js
@@ -632,7 +632,7 @@
routes.v2_wt2html = function( req, res ) {
var v2 = { format: res.local("format") };
if ( v2.format === "pagebundle" ) {
- res.local('env').conf.parsoid.storeDataParsoid = true;
+ res.local('env').storeDataParsoid = true;
}
wt2html( req, res, null, v2 );
};
diff --git a/lib/dom.cleanup.js b/lib/dom.cleanup.js
index 769b471..11c5ba3 100644
--- a/lib/dom.cleanup.js
+++ b/lib/dom.cleanup.js
@@ -91,7 +91,7 @@
dp.dsr[0] = dp.dsr[1];
}
- if ( atTopLevel && env.conf.parsoid.storeDataParsoid ) {
+ if ( atTopLevel && env.storeDataParsoid ) {
DU.stripDataParsoid( node, dp );
}
}
diff --git a/lib/mediawiki.DOMPostProcessor.js
b/lib/mediawiki.DOMPostProcessor.js
index d3c57d2..3d724e7 100644
--- a/lib/mediawiki.DOMPostProcessor.js
+++ b/lib/mediawiki.DOMPostProcessor.js
@@ -246,7 +246,7 @@
}
// holder for data-parsoid
- if ( psd.storeDataParsoid ) {
+ if ( env.storeDataParsoid ) {
DU.setNodeData(document, {
parsoid: {
counter: -1,
@@ -359,7 +359,7 @@
}
// stick data-parsoid in the head
- if ( psd.storeDataParsoid ) {
+ if ( env.storeDataParsoid ) {
var dp = JSON.stringify( DU.getDataParsoid( document ) );
var script = document.createElement("script");
DU.addAttributes(script, {
diff --git a/lib/mediawiki.parser.environment.js
b/lib/mediawiki.parser.environment.js
index 573f84b..733ce52 100644
--- a/lib/mediawiki.parser.environment.js
+++ b/lib/mediawiki.parser.environment.js
@@ -61,6 +61,10 @@
this.linter = new Linter(this);
this.conf.parsoid = parsoidConfig;
+ // Store this in the environment to manipulate it on each request,
+ // if necessary. Avoids having to clone the config.
+ this.storeDataParsoid = parsoidConfig.storeDataParsoid;
+
this.configureLogging();
if ( !wikiConfig ) {
--
To view, visit https://gerrit.wikimedia.org/r/177270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa2d36accb20c8a5218f465a625184d12ba80a44
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