r44593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44592‎ | r44593 | r44594 >
Date:20:49, 14 December 2008
Author:aaron
Status:deferred
Tags:
Comment:
Make getUserList() group properly for logged in users
Modified paths:
  • /trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
@@ -560,16 +560,18 @@
561561 __METHOD__,
562562 array( 'ORDER BY' => 'rev_timestamp DESC' )
563563 );
 564+ // Fetch the list of users and how many votes they reviews
564565 $res = $dbr->select( array( 'revision', 'reader_feedback', 'user' ),
565 - array( 'rfb_user', 'rfb_ip', 'user_name', 'COUNT(*) as n' ),
 566+ # COALESCE() gets the user_name for users, and the IP for anons
 567+ array( 'rfb_user', 'COALESCE(user_name,rfb_ip) AS name', 'COUNT(rfb_rev_id) AS n' ),
566568 array( 'rev_page' => $this->page->getArticleId(),
567569 "rev_id = rfb_rev_id",
568570 "rfb_timestamp >= $cutoff",
569571 // Trigger INDEX usage
570572 "rev_timestamp >= ".$dbr->addQuotes($firstRevTS) ),
571573 __METHOD__,
572 - array( 'GROUP BY' => 'rfb_user, rfb_ip', 'USE INDEX' => array('revision' => 'page_timestamp') ),
573 - array( 'user' => array( 'LEFT JOIN', 'user_id = rfb_user') )
 574+ array( 'GROUP BY' => 'name', 'USE INDEX' => array('revision' => 'page_timestamp') ),
 575+ array( 'user' => array( 'LEFT JOIN', 'rfb_user > 0 AND user_id = rfb_user') )
574576 );
575577 // Output multi-column list
576578 $total = $res->numRows();
@@ -577,7 +579,8 @@
578580 $count = 0;
579581 $html = "<table class='fr_reader_feedback_users'><tr>";
580582 while( $row = $res->fetchObject() ) {
581 - $title = Title::makeTitleSafe( NS_USER, $row->rfb_user ? $row->user_name : $row->rfb_ip );
 583+ $title = Title::makeTitleSafe( NS_USER, $row->name );
 584+ if( is_null($title) ) continue; // bad IP?
582585 $html .= '<td>'.$this->skin->makeLinkObj( $title, $title->getText() )." [{$row->n}]</td>";
583586 $count++;
584587 if( $total > $count && ($count % $columns) == 0 ) {

Status & tagging log