* Fix for interwiki transclusion where target wiki uses query string for title
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 31 Dec 2006 03:04:49 +0000 (03:04 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 31 Dec 2006 03:04:49 +0000 (03:04 +0000)
* Resolve namespaces on interwiki Title objects using canonical namespace names
  if possible (should not happen, though, outside interwiki transclusion... and
  maybe not even then, but it does)

RELEASE-NOTES
includes/Parser.php
includes/Title.php

index b5322f0..4fab361 100644 (file)
@@ -437,6 +437,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   next to the user name and ID.
 * (bug 8392) Display protection status of transcluded pages in the edit page
   template list. Patch by Fyren, with i18n naming tweak.
+* Fix for interwiki transclusion where target wiki uses query string for title
+* Resolve namespaces on interwiki Title objects using canonical namespace names
+  if possible (should not happen, though, outside interwiki transclusion... and
+  maybe not even then, but it does)
 
 
 == Languages updated ==
index 299c221..258f6c3 100644 (file)
@@ -3250,22 +3250,13 @@ class Parser
         * Transclude an interwiki link.
         */
        function interwikiTransclude( $title, $action ) {
-               global $wgEnableScaryTranscluding, $wgCanonicalNamespaceNames;
+               global $wgEnableScaryTranscluding;
 
                if (!$wgEnableScaryTranscluding)
                        return wfMsg('scarytranscludedisabled');
 
-               // The namespace will actually only be 0 or 10, depending on whether there was a leading :
-               // But we'll handle it generally anyway
-               if ( $title->getNamespace() ) {
-                       // Use the canonical namespace, which should work anywhere
-                       $articleName = $wgCanonicalNamespaceNames[$title->getNamespace()] . ':' . $title->getDBkey();
-               } else {
-                       $articleName = $title->getDBkey();
-               }
-
-               $url = str_replace('$1', urlencode($articleName), Title::getInterwikiLink($title->getInterwiki()));
-               $url .= "?action=$action";
+               $url = $title->getFullUrl( "action=$action" );
+               
                if (strlen($url) > 255)
                        return wfMsg('scarytranscludetoolong');
                return $this->fetchScaryTemplateMaybeFromCache($url);
index 40375a7..a8abb6f 100644 (file)
@@ -615,7 +615,19 @@ class Title {
         * @access public
         */
        function getNsText() {
-               global $wgContLang;
+               global $wgContLang, $wgCanonicalNamespaceNames;
+
+               if ( '' != $this->mInterwiki ) {
+                       // This probably shouldn't even happen. ohh man, oh yuck.
+                       // But for interwiki transclusion it sometimes does.
+                       // Shit. Shit shit shit.
+                       //
+                       // Use the canonical namespaces if possible to try to
+                       // resolve a foreign namespace.
+                       if( isset( $wgCanonicalNamespaceNames[$this->mNamespace] ) ) {
+                               return $wgCanonicalNamespaceNames[$this->mNamespace];
+                       }
+               }
                return $wgContLang->getNsText( $this->mNamespace );
        }
        /**
@@ -812,9 +824,10 @@ class Title {
                } else {
                        $baseUrl = $this->getInterwikiLink( $this->mInterwiki );
 
-                       $namespace = $wgContLang->getNsText( $this->mNamespace );
+                       $namespace = wfUrlencode( $this->getNsText() );
                        if ( '' != $namespace ) {
                                # Can this actually happen? Interwikis shouldn't be parsed.
+                               # Yes! It can in interwiki transclusion. But... it probably shouldn't.
                                $namespace .= ':';
                        }
                        $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
@@ -1460,14 +1473,12 @@ class Title {
         * @private
         */
        /* private */ function prefix( $name ) {
-               global $wgContLang;
-
                $p = '';
                if ( '' != $this->mInterwiki ) {
                        $p = $this->mInterwiki . ':';
                }
                if ( 0 != $this->mNamespace ) {
-                       $p .= $wgContLang->getNsText( $this->mNamespace ) . ':';
+                       $p .= $this->getNsText() . ':';
                }
                return $p . $name;
        }