From b3920cc2196517f28691a60ab1d854f39e82f039 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 25 Nov 2004 13:06:40 +0000 Subject: [PATCH] Avoid a lot of wasted time parsing and reparsing titles and fetching and refetching messages on every line of potentially hundreds or thousands shown. --- includes/PageHistory.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 0f42b6f5e3..2b2a429dfd 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -146,14 +146,16 @@ class PageHistory { function historyLine( $ts, $u, $ut, $ns, $ttl, $oid, $c, $isminor, $counter = '' ) { global $wgLang, $wgContLang; - $artname = Title::makeName( $ns, $ttl ); - $last = wfMsg( 'last' ); - $cur = wfMsg( 'cur' ); - $cr = wfMsg( 'currentrev' ); - + static $message; + if( !isset( $message ) ) { + foreach( explode( ' ', 'cur last selectolderversionfordiff selectnewerversionfordiff minoreditletter' ) as $msg ) { + $message[$msg] = wfMsg( $msg ); + } + } + if ( $oid && $this->lastline ) { - $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->mSkin->makeKnownLink( - $artname, $last, "diff=\\1&oldid={$oid}",'' ,'' ,' tabindex="'.$counter.'"' ), $this->lastline ); + $ret = preg_replace( "/!OLDID!([0-9]+)!/", $this->mSkin->makeKnownLinkObj( + $this->mTitle, $message['last'], "diff=\\1&oldid={$oid}",'' ,'' ,' tabindex="'.$counter.'"' ), $this->lastline ); } else { $ret = ''; } @@ -164,43 +166,44 @@ class PageHistory { } else { $q = ''; } - $link = $this->mSkin->makeKnownLink( $artname, $dt, $q ); + $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $dt, $q ); if ( 0 == $u ) { - $ul = $this->mSkin->makeKnownLink( $wgContLang->specialPage( 'Contributions' ), + $contribsPage =& Title::makeTitle( NS_SPECIAL, 'Contributions' ); + $ul = $this->mSkin->makeKnownLinkObj( $contribsPage, htmlspecialchars( $ut ), 'target=' . urlencode( $ut ) ); } else { - $ul = $this->mSkin->makeLink( $wgContLang->getNsText( - Namespace::getUser() ) . ':'.$ut , htmlspecialchars( $ut ) ); + $userPage =& Title::makeTitle( NS_USER, $ut ); + $ul = $this->mSkin->makeLink( $userPage , htmlspecialchars( $ut ) ); } $s = '
  • '; if ( $oid ) { - $curlink = $this->mSkin->makeKnownLink( $artname, $cur, + $curlink = $this->mSkin->makeKnownLinkObj( $this->mTitle, $message['cur'], 'diff=0&oldid='.$oid ); } else { - $curlink = $cur; + $curlink = $message['cur']; } $arbitrary = ''; if( $this->linesonpage > 1) { # XXX: move title texts to javascript $checkmark = ''; if ( !$oid ) { - $arbitrary = ''; + $arbitrary = ''; $checkmark = ' checked="checked"'; } else { if( $counter == 2 ) $checkmark = ' checked="checked"'; - $arbitrary = ''; + $arbitrary = ''; $checkmark = ''; } - $arbitrary .= ''; + $arbitrary .= ''; } $s .= "({$curlink}) (!OLDID!{$oid}!) $arbitrary {$link} {$ul}"; - $s .= $isminor ? ' '.wfMsg( "minoreditletter" ).'': '' ; + $s .= $isminor ? ' '.$message['minoreditletter'].'': '' ; if ( '' != $c && '*' != $c ) { - $c = $this->mSkin->formatcomment($c,$this->mTitle); + $c = $this->mSkin->formatcomment( $c, $this->mTitle ); $s .= " ($c)"; } $s .= '
  • '; -- 2.20.1