From 107489687afa1b3cc6159233f2072df3a99927d3 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 16 Feb 2012 20:13:35 +0000 Subject: [PATCH] Merge r111667 into trunk --- includes/api/ApiQueryAllUsers.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 05fda5b50a..ac112ef982 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -60,10 +60,15 @@ class ApiQueryAllUsers extends ApiQueryBase { $from = is_null( $params['from'] ) ? null : $this->keyToTitle( $params['from'] ); $to = is_null( $params['to'] ) ? null : $this->keyToTitle( $params['to'] ); - $this->addWhereRange( 'user_name', $dir, $from, $to ); + # MySQL doesn't seem to use 'equality propagation' here, so like the + # ActiveUsers special page, we have to use rc_user_text for some cases. + $userFieldToSort = $params['activeusers'] ? 'rc_user_text' : 'user_name'; + + $this->addWhereRange( $userFieldToSort, $dir, $from, $to ); if ( !is_null( $params['prefix'] ) ) { - $this->addWhere( 'user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( $userFieldToSort . + $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); } if ( !is_null( $params['rights'] ) ) { @@ -143,7 +148,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 ); $this->addWhere( "rc_timestamp >= {$db->addQuotes( $timestamp )}" ); - $this->addOption( 'GROUP BY', 'user_name' ); + $this->addOption( 'GROUP BY', $userFieldToSort ); } $this->addOption( 'LIMIT', $sqlLimit ); -- 2.20.1