Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/141056
Change subject: Prevent OutputPage::addWikiText and friends from causing UNIQ
fails
......................................................................
Prevent OutputPage::addWikiText and friends from causing UNIQ fails
If you transclude a special page, OutputPage::addWikiText can cause
problems. This prevents that from happening, by using a new object
if currently in a parsing operation.
Bug: 14562
Bug: 65826
Change-Id: I7c38fa9e2fbd270e45f73f522612451e77ab8cbb
---
M includes/OutputPage.php
M includes/parser/Parser.php
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/56/141056/1
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 8fd7812..815ac12 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1608,7 +1608,7 @@
$oldTidy = $popts->setTidy( $tidy );
$popts->setInterfaceMessage( (bool)$interface );
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $title, $popts,
$linestart, true, $this->mRevisionId
);
@@ -1726,7 +1726,7 @@
$oldLang = $popts->setTargetLanguage( $language );
}
- $parserOutput = $wgParser->parse(
+ $parserOutput = $wgParser->getFreshParser()->parse(
$text, $this->getTitle(), $popts,
$linestart, true, $this->mRevisionId
);
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index c1fce12..9895fa0 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -6333,4 +6333,21 @@
return $html;
}
+
+ /**
+ * Return this parser if its not doing anything, otherwise get a fresh
parser
+ *
+ * You can use this method by doing $myParser =
$wgParser->getFreshParser()
+ * if you're unsure if $wgParser is safe to use.
+ *
+ * @return Parser A parser object that is not parsing anything
+ */
+ public function getFreshParser() {
+ global $wgParserConf;
+ if ( $this->mInParse ) {
+ return new $wgParserConf['class']( $wgParserConf );
+ } else {
+ return $this;
+ }
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/141056
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7c38fa9e2fbd270e45f73f522612451e77ab8cbb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits