Merge "RCFilters UI: Make monobook override of the 'checkmark' more specific"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 953f021..34f6232 100644 (file)
@@ -245,7 +245,7 @@ class Parser {
        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;
@@ -589,6 +589,14 @@ class Parser {
                                        $this->mTitle->getPrefixedDBkey() );
                        }
                }
+
+               # Wrap non-interface parser output in a <div> so it can be targeted
+               # with CSS (T37247)
+               $class = $this->mOptions->getWrapOutputClass();
+               if ( $class !== false && !$this->mOptions->getInterfaceMessage() ) {
+                       $text = Html::rawElement( 'div', [ 'class' => $class ], $text );
+               }
+
                $this->mOutput->setText( $text );
 
                $this->mRevisionId = $oldRevisionId;
@@ -3476,7 +3484,7 @@ class Parser {
 
                if ( !$title->equals( $cacheTitle ) ) {
                        $this->mTplRedirCache[$cacheTitle->getPrefixedDBkey()] =
-                               [ $title->getNamespace(), $cdb = $title->getDBkey() ];
+                               [ $title->getNamespace(), $title->getDBkey() ];
                }
 
                return [ $dom, $title ];
@@ -4392,7 +4400,6 @@ class Parser {
                        $toc = Linker::tocList( $toc, $this->mOptions->getUserLangObj() );
                        $this->mOutput->setTOCHTML( $toc );
                        $toc = self::TOC_START . $toc . self::TOC_END;
-                       $this->mOutput->addModules( 'mediawiki.toc' );
                }
 
                if ( $isMain ) {
@@ -5141,6 +5148,11 @@ class Parser {
                                $internalParamMap = [];
                                foreach ( $internalParamNames as $type => $names ) {
                                        foreach ( $names as $name ) {
+                                               // For grep: img_left, img_right, img_center, img_none,
+                                               // img_baseline, img_sub, img_super, img_top, img_text_top, img_middle,
+                                               // img_bottom, img_text_bottom,
+                                               // img_thumbnail, img_manualthumb, img_framed, img_frameless, img_upright,
+                                               // img_border, img_link, img_alt, img_class
                                                $magicName = str_replace( '-', '_', "img_$name" );
                                                $internalParamMap[$magicName] = [ $type, $name ];
                                        }
@@ -6060,9 +6072,13 @@ class Parser {
        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;