Followup r85884

Fixup the APIs strange way of doing table aliases on a join....

Only used in very few places
This commit is contained in:
Sam Reed 2011-04-30 23:18:34 +00:00
parent 128b544632
commit ab28af877c
4 changed files with 6 additions and 19 deletions

View file

@ -89,8 +89,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
$useIndex = false;
// 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=user_id',
$this->addJoinConds( array( 'ug1' => array( 'INNER JOIN', array( 'ug1.ug_user=user_id',
'ug1.ug_group' => $params['group'] ) ) ) );
}
@ -107,8 +106,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
$sqlLimit = $limit + $groupCount + 1;
$this->addTables( 'user_groups', 'ug2' );
$tname = $this->getAliasedName( 'user_groups', 'ug2' );
$this->addJoinConds( array( $tname => array( 'LEFT JOIN', 'ug2.ug_user=user_id' ) ) );
$this->addJoinConds( array( 'ug2' => array( 'LEFT JOIN', 'ug2.ug_user=user_id' ) ) );
$this->addFields( 'ug2.ug_group ug_group2' );
} else {
$sqlLimit = $limit + 1;

View file

@ -84,22 +84,13 @@ abstract class ApiQueryBase extends ApiBase {
$this->tables = array_merge( $this->tables, $tables );
} else {
if ( !is_null( $alias ) ) {
$tables = $this->getAliasedName( $tables, $alias );
$this->tables[$alias] = $tables;
} else {
$this->tables[] = $tables;
}
$this->tables[] = $tables;
}
}
/**
* Get the SQL for a table name with alias
* @param $table string Table name
* @param $alias string Alias
* @return string SQL
*/
protected function getAliasedName( $table, $alias ) {
return $this->getDB()->tableName( $table ) . ' ' . $alias;
}
/**
* Add a set of JOIN conditions to the internal array
*

View file

@ -179,8 +179,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$this->addWhere( 'rc_user_text != ' . $this->getDB()->addQuotes( $params['excludeuser'] ) );
}
// This is an index optimization for mysql, as done in the Special:Watchlist page
$this->addWhereIf( "rc_timestamp > ''", !isset( $params['start'] ) && !isset( $params['end'] ) && $db->getType() == 'mysql' );

View file

@ -1651,7 +1651,7 @@ abstract class DatabaseBase implements DatabaseType {
}
/**
* @private
* @return string
*/
function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) {
$ret = array();