API: Fix list=deletedrevs paging bug pointed out by Splarka on IRC
[lhc/web/wiklou.git] / includes / ChangesList.php
index ac7ee9c..3efa66f 100644 (file)
@@ -108,11 +108,18 @@ class ChangesList {
        public static function showCharacterDifference( $old, $new ) {
                global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode;
                $szdiff = $new - $old;
+
+               $code = $wgLang->getCode();
+               static $fastCharDiff = array();
+               if ( !isset($fastCharDiff[$code]) ) {
+                       $fastCharDiff[$code] = $wgMiserMode || wfMsgNoTrans( 'rc-change-size' ) === '$1';
+               }
                        
-               $formatedSize = ( $wgMiserMode? 
-                       $wgLang->formatNum($szdiff) : // avoid expensive calculations
-                       wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) )
-                       );
+               $formatedSize = $wgLang->formatNum($szdiff);
+
+               if ( !$fastCharDiff[$code] ) {
+                       $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize );
+               }
                        
                if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
                        $tag = 'strong';
@@ -368,7 +375,7 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         */
        public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
-               global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
+               global $wgLang, $wgRCShowChangedSize, $wgUser;
                wfProfileIn( __METHOD__ );
                # Should patrol-related stuff be shown?
                $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
@@ -473,7 +480,7 @@ class EnhancedChangesList extends ChangesList {
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
        public function recentChangesLine( &$baseRC, $watched = false ) {
-               global $wgLang, $wgContLang, $wgUser;
+               global $wgLang, $wgUser;
                
                wfProfileIn( __METHOD__ );
 
@@ -547,13 +554,14 @@ class EnhancedChangesList extends ChangesList {
                        $showdifflinks = false;
                }
 
-               $time = $wgContLang->time( $rc_timestamp, true, true );
+               $time = $wgLang->time( $rc_timestamp, true, true );
                $rc->watched = $watched;
                $rc->link = $clink;
                $rc->timestamp = $time;
                $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
 
-               # Make "cur" and "diff" links
+               # Make "cur" and "diff" links.  Don't use link(), it's too slow if
+               # called too many times (50% of CPU time on RecentChanges!).
                if( $rc->unpatrolled ) {
                        $rcIdQuery = array( 'rcid' => $rc_id );
                } else {
@@ -562,21 +570,23 @@ class EnhancedChangesList extends ChangesList {
                $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $rc_this_oldid );
                $querydiff = $curIdEq + array( 'diff' => $rc_this_oldid, 'oldid' =>
                        $rc_last_oldid ) + $rcIdQuery;
-               $attribs = array( 'tabindex' => $baseRC->counter );
 
-               # Make "diff" and "cur" links
                if( !$showdifflinks ) {
                        $curLink = $this->message['cur'];
                        $diffLink = $this->message['diff'];
                } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
-                       $curLink = ($rc_type != RC_NEW) ? $this->message['cur']
-                               : $this->skin->linkKnown( $rc->getTitle(), $this->message['cur'], $attribs, $querycur );
+                       if ( $rc_type != RC_NEW ) {
+                               $curLink = $this->message['cur'];
+                       } else {
+                               $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
+                               $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
+                       }
                        $diffLink = $this->message['diff'];
                } else {
-                       $diffLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['diff'], 
-                               $attribs, $querydiff );
-                       $curLink = $this->skin->linkKnown( $rc->getTitle(), $this->message['cur'],
-                               $attribs, $querycur );
+                       $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querydiff ) );
+                       $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
+                       $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
+                       $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
                }
 
                # Make "last" link
@@ -915,7 +925,7 @@ class EnhancedChangesList extends ChangesList {
         * @return string a HTML formated line (generated using $r)
         */
        protected function recentChangesBlockLine( $rcObj ) {
-               global $wgContLang, $wgRCShowChangedSize;
+               global $wgRCShowChangedSize;
 
                wfProfileIn( __METHOD__ );