jenkins-bot has submitted this change and it was merged.

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, 21 insertions(+), 2 deletions(-)

Approvals:
  Aude: Looks good to me, but someone else must approve
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



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..a9e2a3b 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -6333,4 +6333,23 @@
 
                return $html;
        }
+
+       /**
+        * Return this parser if it is not doing anything, otherwise
+        * get a fresh parser. You can use this method by doing
+        * $myParser = $wgParser->getFreshParser(), or more simply
+        * $wgParser->getFreshParser()->parse( ... );
+        * if you're unsure if $wgParser is safe to use.
+        *
+        * @since 1.24
+        * @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: merged
Gerrit-Change-Id: I7c38fa9e2fbd270e45f73f522612451e77ab8cbb
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to