Bartosz Dziewoński has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/355212 )

Change subject: Parser: Better debugging of lock errors ("Did you call 
Parser::parse recursively?")
......................................................................

Parser: Better debugging of lock errors ("Did you call Parser::parse 
recursively?")

Save the backtrace when locking, so that if some code tries locking again,
we can print the lock owner's backtrace for easier debugging.

Change-Id: I6e352b4aa5e7cb35825a66592f6c066d9e8b95c9
---
M includes/parser/Parser.php
1 file changed, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/12/355212/1

diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index ecee0e2..11392de 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -245,7 +245,7 @@
        public $currentRevisionCache;
 
        /**
-        * @var bool Recursive call protection.
+        * @var bool|string Recursive call protection.
         * This variable should be treated as if it were private.
         */
        public $mInParse = false;
@@ -6073,9 +6073,13 @@
        protected function lock() {
                if ( $this->mInParse ) {
                        throw new MWException( "Parser state cleared while 
parsing. "
-                               . "Did you call Parser::parse recursively?" );
+                               . "Did you call Parser::parse recursively? Lock 
is held by: " . $this->mInParse );
                }
-               $this->mInParse = true;
+
+               // Save the backtrace when locking, so that if some code tries 
locking again,
+               // we can print the lock owner's backtrace for easier debugging
+               $e = new Exception;
+               $this->mInParse = $e->getTraceAsString();
 
                $recursiveCheck = new ScopedCallback( function() {
                        $this->mInParse = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/355212
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e352b4aa5e7cb35825a66592f6c066d9e8b95c9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to