Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92247
Change subject: Throw an error if calling parser recursively
......................................................................
Throw an error if calling parser recursively
People accidentally (or sometimes intentionally) calling the
parser recursively has been a major source of bugs over the
years. I think its much better to fail suddenly, instead
of having unclear signs like UNIQ's all over the place.
Change-Id: I0e42aa69835c15a5df7aecb0dc5c3dec946bdf6a
---
M RELEASE-NOTES-1.23
M includes/parser/Parser.php
2 files changed, 12 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/47/92247/1
diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23
index ec7b898..bd46057 100644
--- a/RELEASE-NOTES-1.23
+++ b/RELEASE-NOTES-1.23
@@ -17,6 +17,7 @@
changes and watchlist) and the talk page message indicator are now correctly
updated when the user is viewing old revisions of pages, instead of always
acting as if the latest revision was being viewed.
+* Parser dies early if called recursively
=== API changes in 1.23 ===
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 1f14223..3f9f626 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -212,6 +212,11 @@
var $mLangLinkLanguages;
/**
+ * @var boolean Recursive call protection.
+ */
+ private $mInParse = false;
+
+ /**
* Constructor
*
* @param $conf array
@@ -360,10 +365,15 @@
*/
global $wgUseTidy, $wgAlwaysUseTidy, $wgShowHostnames;
+ if ( $this->mInParse ) {
+ throw new MWException( "Parser::Parse is not allowed to
be called recursively" );
+ }
+
$fname = __METHOD__ . '-' . wfGetCaller();
wfProfileIn( __METHOD__ );
wfProfileIn( $fname );
+ $this->mInParse = true;
$this->startParse( $title, $options, self::OT_HTML, $clearState
);
$this->mInputSize = strlen( $text );
@@ -578,6 +588,7 @@
$this->mRevisionUser = $oldRevisionUser;
$this->mRevisionSize = $oldRevisionSize;
$this->mInputSize = false;
+ $this->mInParse = false;
wfProfileOut( $fname );
wfProfileOut( __METHOD__ );
--
To view, visit https://gerrit.wikimedia.org/r/92247
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e42aa69835c15a5df7aecb0dc5c3dec946bdf6a
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