r49017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49016‎ | r49017 | r49018 >
Date:17:09, 29 March 2009
Author:simetrical
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1234,10 +1234,13 @@
12351235 * have query string parameters already. If so, they will be combined.
12361236 *
12371237 * @param string $url
1238 - * @param string $query
 1238+ * @param mixed $query String or associative array
12391239 * @return string
12401240 */
12411241 function wfAppendQuery( $url, $query ) {
 1242+ if ( is_array( $query ) ) {
 1243+ $query = wfArrayToCGI( $query );
 1244+ }
12421245 if( $query != '' ) {
12431246 if( false === strpos( $url, '?' ) ) {
12441247 $url .= '?';
Index: trunk/phase3/includes/ChangesList.php
@@ -553,7 +553,8 @@
554554 $rc->timestamp = $time;
555555 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
556556
557 - # Make "cur" and "diff" links
 557+ # Make "cur" and "diff" links. Don't use link(), it's too slow if
 558+ # called too many times (50% of CPU time on RecentChanges!).
558559 if( $rc->unpatrolled ) {
559560 $rcIdQuery = array( 'rcid' => $rc_id );
560561 } else {
@@ -564,19 +565,23 @@
565566 $rc_last_oldid ) + $rcIdQuery;
566567 $attribs = array( 'tabindex' => $baseRC->counter );
567568
568 - # Make "diff" and "cur" links
569569 if( !$showdifflinks ) {
570570 $curLink = $this->message['cur'];
571571 $diffLink = $this->message['diff'];
572572 } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
573 - $curLink = ($rc_type != RC_NEW) ? $this->message['cur']
574 - : $this->skin->linkKnown( $rc->getTitle(), $this->message['cur'], $attribs, $querycur );
 573+ if ( $rc_type != RC_NEW ) {
 574+ $curLink = $this->message['cur'];
 575+ } else {
 576+ $curUrl = wfUrlencode( wfAppendQuery( $rc->getTitle()->getLinkUrl(), $querycur ) );
 577+ $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
 578+ }
575579 $diffLink = $this->message['diff'];
576580 } else {
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 );
 581+ $url = $rc->getTitle()->getLinkUrl();
 582+ $diffUrl = wfUrlencode( wfAppendQuery( $url, $querydiff ) );
 583+ $curUrl = wfUrlencode( wfAppendQuery( $url, $querycur ) );
 584+ $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
 585+ $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
581586 }
582587
583588 # Make "last" link

Follow-up revisions

RevisionCommit summaryAuthorDate
r49645Fix braindead wrong escaping from r49017, r49018...simetrical17:07, 19 April 2009

Comments

#Comment by Tbleher (talk | contribs)   16:05, 19 April 2009

This change breaks Special:RecentChanges on my wiki, in that the "?" in the diff link urls beside each revision are encoded as "%3F" (like http://spiele.j-crew.de/w/index.php%3Ftitle=Geschicklichkeitsspiele&curid=1838&diff=8218&oldid=8155&rcid=7592). The rest of the URL looks OK. When clicking on such a URL, the 404 handler of the WebStore extension is called, instead of displaying the diff page. Reverting this patch and the one following it (r49018) fixes this.

#Comment by Simetrical (talk | contribs)   17:08, 19 April 2009

Thanks for the report. It should be fixed in r49645; could you confirm this?

#Comment by Tbleher (talk | contribs)   18:41, 19 April 2009

Wow, that was fast :) This patch indeed fixes the issue I saw. Thanks for the fast response and correction!

#Comment by Brion VIBBER (talk | contribs)   23:19, 28 April 2009

Could we track down what's slow in the link() calls here?

#Comment by Simetrical (talk | contribs)   01:39, 29 April 2009

The fact that they're called 20,000 times per page view on RC when lots of rows are displayed, mainly.  :)

Status & tagging log