Merge "mediawiki.page.gallery.resize: Remove weird mw.hook call"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 61fd9cc..e5917b8 100644 (file)
@@ -2820,6 +2820,9 @@ class Parser {
                $pageLang = $this->getFunctionLang();
 
                switch ( $index ) {
+                       case '!':
+                               $value = '|';
+                               break;
                        case 'currentmonth':
                                $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'm' ) );
                                break;
@@ -5010,9 +5013,9 @@ class Parser {
         * private variables.**
         *
         * @param string $tag The tag to use, e.g. 'hook' for "<hook>"
-        * @param mixed $callback The callback function (and object) to use for the tag
+        * @param callable $callback The callback function (and object) to use for the tag
         * @throws MWException
-        * @return mixed|null The old value of the mTagHooks array associated with the hook
+        * @return callable|null The old value of the mTagHooks array associated with the hook
         */
        public function setHook( $tag, $callback ) {
                $tag = strtolower( $tag );
@@ -5041,9 +5044,9 @@ class Parser {
         * @todo better document or deprecate this
         *
         * @param string $tag The tag to use, e.g. 'hook' for "<hook>"
-        * @param mixed $callback The callback function (and object) to use for the tag
+        * @param callable $callback The callback function (and object) to use for the tag
         * @throws MWException
-        * @return mixed|null The old value of the mTagHooks array associated with the hook
+        * @return callable|null The old value of the mTagHooks array associated with the hook
         */
        function setTransparentTagHook( $tag, $callback ) {
                $tag = strtolower( $tag );
@@ -5082,7 +5085,7 @@ class Parser {
         *   isHTML                    The returned text is HTML, armour it against wikitext transformation
         *
         * @param string $id The magic word ID
-        * @param mixed $callback The callback function (and object) to use
+        * @param callable $callback The callback function (and object) to use
         * @param int $flags A combination of the following flags:
         *     SFH_NO_HASH   No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
         *
@@ -5366,6 +5369,7 @@ class Parser {
                        $ig->add( $title, $label, $alt, $link, $handlerOptions );
                }
                $html = $ig->toHTML();
+               wfRunHooks( 'AfterParserFetchFileAndTitle', array( $this, $ig, &$html ) );
                wfProfileOut( __METHOD__ );
                return $html;
        }
@@ -6335,4 +6339,23 @@ class Parser {
 
                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;
+               }
+       }
 }