Merge "Add missing @throws in Importers"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / Database.php
index 5edf3fd..7f0718c 100644 (file)
@@ -2030,9 +2030,19 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
 
                        if ( is_array( $table ) ) {
                                // A parenthesized group
-                               $joinedTable = '('
-                                       . $this->tableNamesWithIndexClauseOrJOIN( $table, $use_index, $ignore_index, $join_conds )
-                                       . ')';
+                               if ( count( $table ) > 1 ) {
+                                       $joinedTable = '('
+                                               . $this->tableNamesWithIndexClauseOrJOIN( $table, $use_index, $ignore_index, $join_conds )
+                                               . ')';
+                               } else {
+                                       // Degenerate case
+                                       $innerTable = reset( $table );
+                                       $innerAlias = key( $table );
+                                       $joinedTable = $this->tableNameWithAlias(
+                                               $innerTable,
+                                               is_string( $innerAlias ) ? $innerAlias : $innerTable
+                                       );
+                               }
                        } else {
                                $joinedTable = $this->tableNameWithAlias( $table, $alias );
                        }
@@ -3284,14 +3294,15 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * @see WANObjectCache::getWithSetCallback()
         *
         * @param IDatabase $db1
-        * @param IDatabase $dbs,...
+        * @param IDatabase $db2 [optional]
         * @return array Map of values:
         *   - lag: highest lag of any of the DBs or false on error (e.g. replication stopped)
         *   - since: oldest UNIX timestamp of any of the DB lag estimates
         *   - pending: whether any of the DBs have uncommitted changes
+        * @throws DBError
         * @since 1.27
         */
-       public static function getCacheSetOptions( IDatabase $db1 ) {
+       public static function getCacheSetOptions( IDatabase $db1, IDatabase $db2 = null ) {
                $res = [ 'lag' => 0, 'since' => INF, 'pending' => false ];
                foreach ( func_get_args() as $db ) {
                        /** @var IDatabase $db */