From 35296f391f8113dc8d4c3a404b71475ee39e6e67 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 24 Feb 2011 18:46:12 +0000 Subject: [PATCH] Followup to r82739 (bug 27688) Remove u1 table aliases --- includes/api/ApiQueryAllUsers.php | 29 ++++++++++++++--------------- includes/api/ApiQueryUsers.php | 10 +++++----- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 1cdc485c18..95fbbf2c84 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -56,18 +56,18 @@ class ApiQueryAllUsers extends ApiQueryBase { } $limit = $params['limit']; - $this->addTables( 'user', 'u1' ); + $this->addTables( 'user' ); $useIndex = true; if ( !is_null( $params['from'] ) ) { - $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) ); + $this->addWhere( 'user_name >= ' . $db->addQuotes( $this->keyToTitle( $params['from'] ) ) ); } if ( !is_null( $params['to'] ) ) { - $this->addWhere( 'u1.user_name <= ' . $db->addQuotes( $this->keyToTitle( $params['to'] ) ) ); + $this->addWhere( 'user_name <= ' . $db->addQuotes( $this->keyToTitle( $params['to'] ) ) ); } if ( !is_null( $params['prefix'] ) ) { - $this->addWhere( 'u1.user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); + $this->addWhere( 'user_name' . $db->buildLike( $this->keyToTitle( $params['prefix'] ), $db->anyString() ) ); } if ( !is_null( $params['rights'] ) ) { @@ -90,12 +90,12 @@ class ApiQueryAllUsers extends ApiQueryBase { // Filter only users that belong to a given group $this->addTables( 'user_groups', 'ug1' ); $ug1 = $this->getAliasedName( 'user_groups', 'ug1' ); - $this->addJoinConds( array( $ug1 => array( 'INNER JOIN', array( 'ug1.ug_user=u1.user_id', + $this->addJoinConds( array( $ug1 => array( 'INNER JOIN', array( 'ug1.ug_user=user_id', 'ug1.ug_group' => $params['group'] ) ) ) ); } if ( $params['witheditsonly'] ) { - $this->addWhere( 'u1.user_editcount > 0' ); + $this->addWhere( 'user_editcount > 0' ); } if ( $fld_groups || $fld_rights ) { @@ -106,7 +106,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addTables( 'user_groups', 'ug2' ); $tname = $this->getAliasedName( 'user_groups', 'ug2' ); - $this->addJoinConds( array( $tname => array( 'LEFT JOIN', 'ug2.ug_user=u1.user_id' ) ) ); + $this->addJoinConds( array( $tname => array( 'LEFT JOIN', 'ug2.ug_user=user_id' ) ) ); $this->addFields( 'ug2.ug_group ug_group2' ); } else { $sqlLimit = $limit + 1; @@ -115,7 +115,7 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( $fld_blockinfo ) { $this->addTables( 'ipblocks' ); $this->addJoinConds( array( - 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ), + 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ), ) ); $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) ); } @@ -123,16 +123,15 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addOption( 'LIMIT', $sqlLimit ); $this->addFields( array( - 'u1.user_name', - 'u1.user_id' + 'user_name', + 'user_id' ) ); - $this->addFieldsIf( 'u1.user_editcount', $fld_editcount ); - $this->addFieldsIf( 'u1.user_registration', $fld_registration ); + $this->addFieldsIf( 'user_editcount', $fld_editcount ); + $this->addFieldsIf( 'user_registration', $fld_registration ); - $this->addOption( 'ORDER BY', 'u1.user_name' ); + $this->addOption( 'ORDER BY', 'user_name' ); if ( $useIndex ) { - $u1 = $this->getAliasedName( 'user', 'u1' ); - $this->addOption( 'USE INDEX', array( $u1 => 'user_name' ) ); + $this->addOption( 'USE INDEX', array( 'user' => 'user_name' ) ); } $res = $this->select( __METHOD__ ); diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 7cec1e9120..818b681ae7 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -110,19 +110,19 @@ if ( !defined( 'MEDIAWIKI' ) ) { } if ( count( $goodNames ) ) { - $this->addTables( 'user', 'u1' ); - $this->addFields( 'u1.*' ); - $this->addWhereFld( 'u1.user_name', $goodNames ); + $this->addTables( 'user' ); + $this->addFields( '*' ); + $this->addWhereFld( 'user_name', $goodNames ); if ( isset( $this->prop['groups'] ) ) { $this->addTables( 'user_groups' ); - $this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=u1.user_id' ) ) ); + $this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=user_id' ) ) ); $this->addFields( 'ug_group' ); } if ( isset( $this->prop['blockinfo'] ) ) { $this->addTables( 'ipblocks' ); $this->addJoinConds( array( - 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ), + 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=user_id' ), ) ); $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) ); } -- 2.20.1