(bug 14995) Some link fragments in the interface stopped appearing, because Title...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 1 Aug 2008 00:47:26 +0000 (00:47 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 1 Aug 2008 00:47:26 +0000 (00:47 +0000)
RELEASE-NOTES
includes/Linker.php
includes/Title.php

index 3a66055..bd70051 100644 (file)
@@ -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 ===
 
index f129f82..628ee89 100644 (file)
@@ -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 <a> 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' ) );
                        }
index d1e4722..b874b15 100644 (file)
@@ -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);