Merge "Don't include images/categories when behind a local interwiki prefix"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index e5917b8..36f306d 100644 (file)
@@ -211,7 +211,7 @@ class Parser {
        var $mLangLinkLanguages;
 
        /**
-        * @var boolean Recursive call protection.
+        * @var bool Recursive call protection.
         * This variable should be treated as if it were private.
         */
        public $mInParse = false;
@@ -349,7 +349,7 @@ class Parser {
         * Convert wikitext to HTML
         * Do not call this function recursively.
         *
-        * @param string $text text we want to parse
+        * @param string $text Text we want to parse
         * @param Title $title
         * @param ParserOptions $options
         * @param bool $linestart
@@ -798,7 +798,7 @@ class Parser {
        /**
         * Get the ParserOptions object
         *
-        * @return ParserOptions object
+        * @return ParserOptions
         */
        function getOptions() {
                return $this->mOptions;
@@ -843,7 +843,7 @@ class Parser {
         * @since 1.19
         *
         * @throws MWException
-        * @return Language|null
+        * @return Language
         */
        public function getTargetLanguage() {
                $target = $this->mOptions->getTargetLanguage();
@@ -1434,7 +1434,7 @@ class Parser {
         *
         * @param string $text
         *
-        * @return string the altered text
+        * @return string The altered text
         */
        function doAllQuotes( $text ) {
                wfProfileIn( __METHOD__ );
@@ -2002,10 +2002,12 @@ class Parser {
                        wfProfileOut( __METHOD__ . "-e1" );
                        wfProfileIn( __METHOD__ . "-misc" );
 
+                       $origLink = $m[1];
+
                        # Don't allow internal links to pages containing
                        # PROTO: where PROTO is a valid URL protocol; these
                        # should be external links.
-                       if ( preg_match( '/^(?i:' . $this->mUrlProtocols . ')/', $m[1] ) ) {
+                       if ( preg_match( '/^(?i:' . $this->mUrlProtocols . ')/', $origLink ) ) {
                                $s .= $prefix . '[[' . $line;
                                wfProfileOut( __METHOD__ . "-misc" );
                                continue;
@@ -2013,12 +2015,12 @@ class Parser {
 
                        # Make subpage if necessary
                        if ( $useSubpages ) {
-                               $link = $this->maybeDoSubpageLink( $m[1], $text );
+                               $link = $this->maybeDoSubpageLink( $origLink, $text );
                        } else {
-                               $link = $m[1];
+                               $link = $origLink;
                        }
 
-                       $noforce = ( substr( $m[1], 0, 1 ) !== ':' );
+                       $noforce = ( substr( $origLink, 0, 1 ) !== ':' );
                        if ( !$noforce ) {
                                # Strip off leading ':'
                                $link = substr( $link, 1 );
@@ -2094,7 +2096,7 @@ class Parser {
                        }
 
                        # Link not escaped by : , create the various objects
-                       if ( $noforce ) {
+                       if ( $noforce && !$nt->wasLocalInterwiki() ) {
                                # Interwikis
                                wfProfileIn( __METHOD__ . "-interwiki" );
                                if (