Merge "Don't include images/categories when behind a local interwiki prefix"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 9 Aug 2014 11:51:07 +0000 (11:51 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 9 Aug 2014 11:51:07 +0000 (11:51 +0000)
RELEASE-NOTES-1.24
includes/Title.php
includes/parser/Parser.php
includes/title/MediaWikiTitleCodec.php

index d68d529..3fa491c 100644 (file)
@@ -131,9 +131,12 @@ production.
 * (bug 66440) The MediaWiki web installer will now allow you to choose the skins
   to enable (from the ones included in download tarball) and decide which one
   should be the default.
-* (bug 68085) Links of the form [[localInterwikiPrefix:languageCode:pageTitle]],
+* (bug 68085, 68802) Links like [[localInterwikiPrefix:languageCode:pageTitle]],
   where localInterwikiPrefix is a member of the $wgLocalInterwikis array, will
-  no longer be displayed in the sidebar when $wgInterwikiMagic is true.
+  no longer be displayed in the sidebar when $wgInterwikiMagic is true. In a
+  similar way, links like [[localInterwikiPrefix:File:Image.png]] and
+  [[localInterwikiPrefix:Category:Hello]] will now render as regular links, and
+  will not include the file or add the page to the category.
 * New special page, MyLanguages, to redirect users to subpages with localised
   versions of a page. (Integrated from Extension:Translate)
 * MediaWiki now supports multiple password types, including bcrypt and PBKDF2.
index 2481178..8e06087 100644 (file)
@@ -74,6 +74,9 @@ class Title {
        /** @var string Interwiki prefix */
        public $mInterwiki = '';
 
+       /** @var bool Was this Title created from a string with a local interwiki prefix? */
+       private $mLocalInterwiki = false;
+
        /** @var string Title fragment (i.e. the bit after the #) */
        public $mFragment = '';
 
@@ -823,6 +826,15 @@ class Title {
                return $this->mInterwiki;
        }
 
+       /**
+        * Was this a local interwiki link?
+        *
+        * @return bool
+        */
+       public function wasLocalInterwiki() {
+               return $this->mLocalInterwiki;
+       }
+
        /**
         * Determine whether the object refers to a page within
         * this project and is transcludable.
@@ -3291,6 +3303,7 @@ class Title {
                # Fill fields
                $this->setFragment( '#' . $parts['fragment'] );
                $this->mInterwiki = $parts['interwiki'];
+               $this->mLocalInterwiki = $parts['local_interwiki'];
                $this->mNamespace = $parts['namespace'];
                $this->mUserCaseDBKey = $parts['user_case_dbkey'];
 
index 90c49c4..36f306d 100644 (file)
@@ -2096,16 +2096,14 @@ class Parser {
                        }
 
                        # Link not escaped by : , create the various objects
-                       if ( $noforce ) {
+                       if ( $noforce && !$nt->wasLocalInterwiki() ) {
                                # Interwikis
                                wfProfileIn( __METHOD__ . "-interwiki" );
-                               # The final condition here is due to bug 68085
                                if (
                                        $iw && $this->mOptions->getInterwikiMagic() && $nottalk && (
                                                Language::fetchLanguageName( $iw, null, 'mw' ) ||
                                                in_array( $iw, $wgExtraInterlanguageLinkPrefixes )
-                                       ) && substr_compare( $this->getTargetLanguage()->lc( ltrim( $origLink ) ),
-                                               $iw, 0, strlen( $iw ) ) === 0
+                                       )
                                ) {
                                        # Bug 24502: filter duplicates
                                        if ( !isset( $this->mLangLinkLanguages[$iw] ) ) {
index 12b7143..6ca0799 100644 (file)
@@ -206,6 +206,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                # Initialisation
                $parts = array(
                        'interwiki' => '',
+                       'local_interwiki' => false,
                        'fragment' => '',
                        'namespace' => $defaultNamespace,
                        'dbkey' => $dbkey,
@@ -282,6 +283,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                                                                $mainPage = Title::newMainPage();
                                                                return array(
                                                                        'interwiki' => $mainPage->getInterwiki(),
+                                                                       'local_interwiki' => true,
                                                                        'fragment' => $mainPage->getFragment(),
                                                                        'namespace' => $mainPage->getNamespace(),
                                                                        'dbkey' => $mainPage->getDBkey(),
@@ -289,6 +291,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
                                                                );
                                                        }
                                                        $parts['interwiki'] = '';
+                                                       # local interwikis should behave like initial-colon links
+                                                       $parts['local_interwiki'] = true;
 
                                                        # Do another namespace split...
                                                        continue 2;