From e3e1cef83c9af2a48a281392774c077f11cfa6db Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 31 Dec 2006 03:04:49 +0000 Subject: [PATCH] * 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) --- RELEASE-NOTES | 4 ++++ includes/Parser.php | 15 +++------------ includes/Title.php | 21 ++++++++++++++++----- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b5322f0f74..4fab361fe1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Parser.php b/includes/Parser.php index 299c221296..258f6c390a 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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); diff --git a/includes/Title.php b/includes/Title.php index 40375a7707..a8abb6fe1c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; } -- 2.20.1