r38325 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38324‎ | r38325 | r38326 >
Date:00:47, 1 August 2008
Author:simetrical
Status:old
Tags:
Comment:
(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? :)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -159,7 +159,9 @@
160160 * @param $options mixed String or array of strings:
161161 * 'known': Page is known to exist, so don't check if it does.
162162 * 'broken': Page is known not to exist, so don't check if it does.
163 - * 'noclasses': Don't add any classes automatically (includes "new", "stub", "mw-redirect"). Only use the class attribute provided, if any.
 163+ * 'noclasses': Don't add any classes automatically (includes "new",
 164+ * "stub", "mw-redirect"). Only use the class attribute provided, if
 165+ * any.
164166 * @return string HTML <a> attribute
165167 */
166168 public function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
@@ -218,8 +220,11 @@
219221 $query['action'] = 'edit';
220222 $query['redlink'] = '1';
221223 }
222 -
223 - return $target->getLocalURL( wfArrayToCGI( $query ) );
 224+ $ret = $target->getLocalURL( $query );
 225+ if( $target->getFragment() !== '' ) {
 226+ $ret .= '#'.$target->getFragment();
 227+ }
 228+ return $ret;
224229 }
225230
226231 private function linkAttribs( $target, $attribs, $options ) {
@@ -1219,7 +1224,7 @@
12201225 $sectionTitle = Title::newFromText( '#' . $section);
12211226 } else {
12221227 $sectionTitle = wfClone( $title );
1223 - $sectionTitle->mFragment = $section;
 1228+ $sectionTitle->setFragment( $section );
12241229 }
12251230 $link = $this->link( $sectionTitle, wfMsgForContent( 'sectionlink' ) );
12261231 }
Index: trunk/phase3/includes/Title.php
@@ -745,14 +745,19 @@
746746 * Get a real URL referring to this title, with interwiki link and
747747 * fragment
748748 *
749 - * @param string $query an optional query string, not used
750 - * for interwiki links
 749+ * @param array $query an optional query string, not used for interwiki
 750+ * links. Can be specified as an associative array as well, e.g.,
 751+ * array( 'action' => 'edit' ) (keys and values will be URL-escaped).
751752 * @param string $variant language variant of url (for sr, zh..)
752753 * @return string the URL
753754 */
754755 public function getFullURL( $query = '', $variant = false ) {
755756 global $wgContLang, $wgServer, $wgRequest;
756757
 758+ if( is_array( $query ) ) {
 759+ $query = wfArrayToCGI( $query );
 760+ }
 761+
757762 if ( '' == $this->mInterwiki ) {
758763 $url = $this->getLocalUrl( $query, $variant );
759764
@@ -784,8 +789,10 @@
785790 /**
786791 * Get a URL with no fragment or server name. If this page is generated
787792 * with action=render, $wgServer is prepended.
788 - * @param string $query an optional query string; if not specified,
789 - * $wgArticlePath will be used.
 793+ * @param mixed $query an optional query string; if not specified,
 794+ * $wgArticlePath will be used. Can be specified as an associative array
 795+ * as well, e.g., array( 'action' => 'edit' ) (keys and values will be
 796+ * URL-escaped).
790797 * @param string $variant language variant of url (for sr, zh..)
791798 * @return string the URL
792799 */
@@ -793,6 +800,10 @@
794801 global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
795802 global $wgVariantArticlePath, $wgContLang, $wgUser;
796803
 804+ if( is_array( $query ) ) {
 805+ $query = wfArrayToCGI( $query );
 806+ }
 807+
797808 // internal links should point to same variant as current page (only anonymous users)
798809 if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){
799810 $pref = $wgContLang->getPreferredVariant(false);
Index: trunk/phase3/RELEASE-NOTES
@@ -48,6 +48,7 @@
4949 * Recursion loop check added to Categoryfinder class
5050 * Fixed few performance troubles of large job queue processing
5151 * Not setting various parameters in Foreign Repos now fails more gracefully
 52+* (bug 14995) Some link fragments in the interface stopped appearing
5253
5354 === API changes in 1.14 ===
5455

Follow-up revisions

RevisionCommit summaryAuthorDate
r38330(bug 14995 again) Fix behavior of link() when it's provided with Titles that ...simetrical01:47, 1 August 2008
r38331Fix regression from r38325 -- caused first character of section name in a his...brion02:02, 1 August 2008

Status & tagging log