Followup r85884
authorSam Reed <reedy@users.mediawiki.org>
Sat, 30 Apr 2011 23:18:34 +0000 (23:18 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 30 Apr 2011 23:18:34 +0000 (23:18 +0000)
Fixup the APIs strange way of doing table aliases on a join....

Only used in very few places

includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryWatchlist.php
includes/db/Database.php

index 0363436..7552da9 100644 (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;
index c9c2273..3812ba1 100644 (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
         *
index 17e8e0c..d7bc60b 100644 (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' );
 
index 77f7c7c..a3d8a3a 100644 (file)
@@ -1651,7 +1651,7 @@ abstract class DatabaseBase implements DatabaseType {
        }
 
        /**
-        * @private
+        * @return string
         */
        function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) {
                $ret = array();