r53538 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53537‎ | r53538 | r53539 >
Date:09:40, 20 July 2009
Author:ialex
Status:ok
Tags:
Comment:
* refactor Special:ActiveUser's SQL query to use options on $query rather than hardcoding it in $query['tables']
* fix case: use Activeusers to match aliases in localisation
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialActiveusers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -3220,7 +3220,7 @@
32213221 'Newimages' => 'changes',
32223222 'Newpages' => 'changes',
32233223 'Log' => 'changes',
3224 - 'Tags' => 'changes',
 3224+ 'Tags' => 'changes',
32253225
32263226 'Upload' => 'media',
32273227 'Listfiles' => 'media',
@@ -3229,7 +3229,7 @@
32303230 'Filepath' => 'media',
32313231
32323232 'Listusers' => 'users',
3233 - 'ActiveUsers' => 'users',
 3233+ 'Activeusers' => 'users',
32343234 'Listgrouprights' => 'users',
32353235 'Ipblocklist' => 'users',
32363236 'Contributions' => 'users',
Index: trunk/phase3/includes/specials/SpecialActiveusers.php
@@ -47,33 +47,36 @@
4848
4949 function getQueryInfo() {
5050 $dbr = wfGetDB( DB_SLAVE );
51 - $conds = array('rc_user > 0'); // Users - no anons
 51+ $conds = array( 'rc_user > 0' ); // Users - no anons
5252 $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
5353 $conds[] = 'rc_log_type IS NULL OR rc_log_type != "newusers"';
54 - $useIndex = $dbr->useIndexClause( 'rc_user_text' );
5554 if( $this->requestedUser != '' ) {
5655 $conds[] = 'rc_user_text >= ' . $dbr->addQuotes( $this->requestedUser );
5756 }
5857
59 - list( $recentchanges, $ipblocks, $user ) = $dbr->tableNamesN( 'recentchanges', 'ipblocks', 'user' );
60 -
6158 $query = array(
62 - 'tables' => "$recentchanges $useIndex
63 - INNER JOIN $user ON rc_user_text=user_name
64 - LEFT JOIN $ipblocks ON user_id=ipb_user AND ipb_auto=0 AND ipb_deleted=1 ",
 59+ 'tables' => array( 'recentchanges', 'user', 'ipblocks' ),
6560 'fields' => array( 'rc_user_text AS user_name', // inheritance
6661 'rc_user_text', // for Pager
6762 'user_id',
6863 'COUNT(*) AS recentedits',
69 - 'MAX(ipb_user) AS blocked' ),
70 - 'options' => array( 'GROUP BY' => 'rc_user_text' ),
 64+ 'MAX(ipb_user) AS blocked'
 65+ ),
 66+ 'options' => array(
 67+ 'GROUP BY' => 'rc_user_text',
 68+ 'USE INDEX' => array( 'recentchanges' => 'rc_user_text' )
 69+ ),
 70+ 'join_conds' => array(
 71+ 'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
 72+ 'ipblocks' => array( 'LEFT JOIN', 'user_id=ipb_user AND ipb_auto=0 AND ipb_deleted=1' ),
 73+ ),
7174 'conds' => $conds
7275 );
7376 return $query;
7477 }
7578
7679 function formatRow( $row ) {
77 - $userName = $row->rc_user_text;
 80+ $userName = $row->user_name;
7881 $userPage = Title::makeTitle( NS_USER, $userName );
7982 $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
8083
@@ -123,7 +126,7 @@
124127 * Constructor
125128 */
126129 public function __construct() {
127 - parent::__construct( 'ActiveUsers' );
 130+ parent::__construct( 'Activeusers' );
128131 }
129132
130133 /**

Status & tagging log