From ea9587e3b03c724c82558f27581c9e2a0ef053a8 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 1 Aug 2008 00:47:26 +0000 Subject: [PATCH] (bug 14995) Some link fragments in the interface stopped appearing, because Title::getLocalURL() doesn't include the fragment. For some reason Title::getFullURL() does, however . . . more functions to clean up? :) --- RELEASE-NOTES | 1 + includes/Linker.php | 13 +++++++++---- includes/Title.php | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3a660559ee..bd70051d59 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -48,6 +48,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Recursion loop check added to Categoryfinder class * Fixed few performance troubles of large job queue processing * Not setting various parameters in Foreign Repos now fails more gracefully +* (bug 14995) Some link fragments in the interface stopped appearing === API changes in 1.14 === diff --git a/includes/Linker.php b/includes/Linker.php index f129f82e66..628ee892f4 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -159,7 +159,9 @@ class Linker { * @param $options mixed String or array of strings: * 'known': Page is known to exist, so don't check if it does. * 'broken': Page is known not to exist, so don't check if it does. - * 'noclasses': Don't add any classes automatically (includes "new", "stub", "mw-redirect"). Only use the class attribute provided, if any. + * 'noclasses': Don't add any classes automatically (includes "new", + * "stub", "mw-redirect"). Only use the class attribute provided, if + * any. * @return string HTML attribute */ public function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) { @@ -218,8 +220,11 @@ class Linker { $query['action'] = 'edit'; $query['redlink'] = '1'; } - - return $target->getLocalURL( wfArrayToCGI( $query ) ); + $ret = $target->getLocalURL( $query ); + if( $target->getFragment() !== '' ) { + $ret .= '#'.$target->getFragment(); + } + return $ret; } private function linkAttribs( $target, $attribs, $options ) { @@ -1219,7 +1224,7 @@ class Linker { $sectionTitle = Title::newFromText( '#' . $section); } else { $sectionTitle = wfClone( $title ); - $sectionTitle->mFragment = $section; + $sectionTitle->setFragment( $section ); } $link = $this->link( $sectionTitle, wfMsgForContent( 'sectionlink' ) ); } diff --git a/includes/Title.php b/includes/Title.php index d1e4722281..b874b150e0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -745,14 +745,19 @@ class Title { * Get a real URL referring to this title, with interwiki link and * fragment * - * @param string $query an optional query string, not used - * for interwiki links + * @param array $query an optional query string, not used for interwiki + * links. Can be specified as an associative array as well, e.g., + * array( 'action' => 'edit' ) (keys and values will be URL-escaped). * @param string $variant language variant of url (for sr, zh..) * @return string the URL */ public function getFullURL( $query = '', $variant = false ) { global $wgContLang, $wgServer, $wgRequest; + if( is_array( $query ) ) { + $query = wfArrayToCGI( $query ); + } + if ( '' == $this->mInterwiki ) { $url = $this->getLocalUrl( $query, $variant ); @@ -784,8 +789,10 @@ class Title { /** * Get a URL with no fragment or server name. If this page is generated * with action=render, $wgServer is prepended. - * @param string $query an optional query string; if not specified, - * $wgArticlePath will be used. + * @param mixed $query an optional query string; if not specified, + * $wgArticlePath will be used. Can be specified as an associative array + * as well, e.g., array( 'action' => 'edit' ) (keys and values will be + * URL-escaped). * @param string $variant language variant of url (for sr, zh..) * @return string the URL */ @@ -793,6 +800,10 @@ class Title { global $wgArticlePath, $wgScript, $wgServer, $wgRequest; global $wgVariantArticlePath, $wgContLang, $wgUser; + if( is_array( $query ) ) { + $query = wfArrayToCGI( $query ); + } + // internal links should point to same variant as current page (only anonymous users) if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){ $pref = $wgContLang->getPreferredVariant(false); -- 2.20.1