From: jenkins-bot Date: Thu, 30 Nov 2017 04:30:28 +0000 (+0000) Subject: Merge "Database: Fix degenerate parenthesized joins" X-Git-Tag: 1.31.0-rc.0~1351 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=b419ffba1976a3f908c78a3b7cd1efbe0c34d8f3;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Database: Fix degenerate parenthesized joins" --- b419ffba1976a3f908c78a3b7cd1efbe0c34d8f3 diff --combined includes/libs/rdbms/database/Database.php index 5edf3fddde,b9367791c7..e10746c732 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@@ -461,12 -461,9 +461,12 @@@ abstract class Database implements IDat protected function ignoreErrors( $ignoreErrors = null ) { $res = $this->getFlag( self::DBO_IGNORE ); if ( $ignoreErrors !== null ) { - $ignoreErrors - ? $this->setFlag( self::DBO_IGNORE ) - : $this->clearFlag( self::DBO_IGNORE ); + // setFlag()/clearFlag() do not allow DBO_IGNORE changes for sanity + if ( $ignoreErrors ) { + $this->mFlags |= self::DBO_IGNORE; + } else { + $this->mFlags &= ~self::DBO_IGNORE; + } } return $res; @@@ -624,10 -621,6 +624,10 @@@ } public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) { + if ( ( $flag & self::DBO_IGNORE ) ) { + throw new \UnexpectedValueException( "Modifying DBO_IGNORE is not allowed." ); + } + if ( $remember === self::REMEMBER_PRIOR ) { array_push( $this->priorFlags, $this->mFlags ); } @@@ -635,10 -628,6 +635,10 @@@ } public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) { + if ( ( $flag & self::DBO_IGNORE ) ) { + throw new \UnexpectedValueException( "Modifying DBO_IGNORE is not allowed." ); + } + if ( $remember === self::REMEMBER_PRIOR ) { array_push( $this->priorFlags, $this->mFlags ); } @@@ -2030,9 -2019,19 +2030,19 @@@ 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 ); }