From 7508ef184e0af64c4b18af9d4c921a08eeb27c30 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Sun, 29 Mar 2009 17:09:47 +0000 Subject: [PATCH] Remove a couple of link() calls in enhanced RC diff and cur links are now created using raw HTML instead of link(), which they didn't really need anyway. I didn't see any other obvious candidates for conversion to raw HTML, since other things tend to need fancy classes and have lots of other logic. It's possible link() could be made faster, too. --- includes/ChangesList.php | 21 +++++++++++++-------- includes/GlobalFunctions.php | 5 ++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/includes/ChangesList.php b/includes/ChangesList.php index ac7ee9c89c..73b8a3ed9c 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -553,7 +553,8 @@ class EnhancedChangesList extends ChangesList { $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 { @@ -564,19 +565,23 @@ class EnhancedChangesList extends ChangesList { $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 = wfUrlencode( wfAppendQuery( $rc->getTitle()->getLinkUrl(), $querycur ) ); + $curLink = "counter}\">{$this->message['cur']}"; + } $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 ); + $url = $rc->getTitle()->getLinkUrl(); + $diffUrl = wfUrlencode( wfAppendQuery( $url, $querydiff ) ); + $curUrl = wfUrlencode( wfAppendQuery( $url, $querycur ) ); + $diffLink = "counter}\">{$this->message['diff']}"; + $curLink = "counter}\">{$this->message['cur']}"; } # Make "last" link diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9afb3ad2b7..f5eb274677 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1234,10 +1234,13 @@ function wfCgiToArray( $query ) { * have query string parameters already. If so, they will be combined. * * @param string $url - * @param string $query + * @param mixed $query String or associative array * @return string */ function wfAppendQuery( $url, $query ) { + if ( is_array( $query ) ) { + $query = wfArrayToCGI( $query ); + } if( $query != '' ) { if( false === strpos( $url, '?' ) ) { $url .= '?'; -- 2.20.1