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;
}
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 );
}
}
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 );
}
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 );
}