r49010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49009‎ | r49010 | r49011 >
Date:16:02, 29 March 2009
Author:simetrical
Status:ok
Tags:
Comment:
Use link() instead of make*Link*()

Preparatory to some optimization work. Also fix a bug in last commit,
so if this causes problems, revert that one too.
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -227,6 +227,13 @@
228228 return $ret;
229229 }
230230
 231+ /**
 232+ * Identical to link(), except $options defaults to 'known'.
 233+ */
 234+ public function linkKnown( $target, $text = null, $customAttribs = array(), $query = array(), $options = 'known' ) {
 235+ return $this->link( $target, $text, $customAttribs, $query, $options );
 236+ }
 237+
231238 private function linkUrl( $target, $query, $options ) {
232239 wfProfileIn( __METHOD__ );
233240 # We don't want to include fragments for broken links, because they
Index: trunk/phase3/includes/ChangesList.php
@@ -484,7 +484,7 @@
485485 // FIXME: Would be good to replace this extract() call with something
486486 // that explicitly initializes variables.
487487 extract( $rc->mAttribs );
488 - $curIdEq = 'curid=' . $rc_cur_id;
 488+ $curIdEq = array( 'curid' => $rc_cur_id );
489489
490490 # If it's a new day, add the headline and flush the cache
491491 $date = $wgLang->date( $rc_timestamp, true );
@@ -509,19 +509,21 @@
510510 // Page moves
511511 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
512512 $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
513 - $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
514 - $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
 513+ $clink = wfMsg( $msg, $this->skin->linkKnown( $rc->getTitle(), null,
 514+ array(), array( 'redirect' => 'no' ) ),
 515+ $this->skin->linkKnown( $rc->getMovedToTitle() ) );
515516 // New unpatrolled pages
516517 } else if( $rc->unpatrolled && $rc_type == RC_NEW ) {
517 - $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
 518+ $clink = $this->skin->linkKnown( $rc->getTitle(), null, array(),
 519+ array( 'rcid' => $rc_id ) );
518520 // Log entries
519521 } else if( $rc_type == RC_LOG ) {
520522 if( $rc_log_type ) {
521523 $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type );
522 - $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle,
 524+ $clink = '(' . $this->skin->linkKnown( $logtitle,
523525 LogPage::logName($rc_log_type) ) . ')';
524526 } else {
525 - $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' );
 527+ $clink = $this->skin->link( $rc->getTitle() );
526528 }
527529 $watched = false;
528530 // Log entries (old format) and special pages
@@ -530,14 +532,14 @@
531533 if ( $specialName == 'Log' ) {
532534 # Log updates, etc
533535 $logname = LogPage::logName( $logtype );
534 - $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
 536+ $clink = '(' . $this->skin->linkKnown( $rc->getTitle(), $logname ) . ')';
535537 } else {
536538 wfDebug( "Unexpected special page in recentchanges\n" );
537539 $clink = '';
538540 }
539541 // Edits
540542 } else {
541 - $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
 543+ $clink = $this->skin->linkKnown( $rc->getTitle() );
542544 }
543545
544546 # Don't show unusable diff links
@@ -553,26 +555,28 @@
554556
555557 # Make "cur" and "diff" links
556558 if( $rc->unpatrolled ) {
557 - $rcIdQuery = "&rcid={$rc_id}";
 559+ $rcIdQuery = array( 'rcid' => $rc_id );
558560 } else {
559 - $rcIdQuery = '';
 561+ $rcIdQuery = array();
560562 }
561 - $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
562 - $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
563 - $aprops = ' tabindex="'.$baseRC->counter.'"';
 563+ $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $rc_this_oldid );
 564+ $querydiff = $curIdEq + array( 'diff' => $rc_this_oldid, 'oldid' =>
 565+ $rc_last_oldid ) + $rcIdQuery;
 566+ $attribs = array( 'tabindex' => $baseRC->counter );
564567
565 - # Make "diff" an "cur" links
 568+ # Make "diff" and "cur" links
566569 if( !$showdifflinks ) {
567570 $curLink = $this->message['cur'];
568571 $diffLink = $this->message['diff'];
569572 } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
570573 $curLink = ($rc_type != RC_NEW) ? $this->message['cur']
571 - : $this->skin->makeKnownLinkObj( $rc->getTitle(),
572 - $this->message['cur'], $querycur, '' ,'', $aprops );
 574+ : $this->skin->linkKnown( $rc->getTitle(), $this->message['cur'], $attribs, $querycur );
573575 $diffLink = $this->message['diff'];
574576 } else {
575 - $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
576 - $querydiff, '' ,'', $aprops );
 577+ $diffLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['diff'],
 578+ $attribs, $querydiff );
 579+ $curLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['cur'],
 580+ $attribs, $querycur );
577581 }
578582
579583 # Make "last" link
@@ -581,8 +585,8 @@
582586 } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
583587 $lastLink = $this->message['last'];
584588 } else {
585 - $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
586 - $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
 589+ $lastLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['last'],
 590+ array(), $curIdEq + array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) + $rcIdQuery );
587591 }
588592
589593 # Make user links

Status & tagging log