diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 09:20:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 09:20:55 +0100 |
commit | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (patch) | |
tree | 31882fdc36540fecfd62e5011fc38515e504a3db /includes/db | |
parent | 6ca0c5e0a943b64b4e3d0a11a80c5679f7252e64 (diff) |
Update to MediaWiki 1.17.1
Diffstat (limited to 'includes/db')
-rw-r--r-- | includes/db/DatabaseOracle.php | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 4fe3e980..3c4d00ac 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -275,6 +275,8 @@ class DatabaseOracle extends DatabaseBase { # removed putenv calls because they interfere with the system globaly $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' ); $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' ); + $this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' ); + return $this->mConn; } @@ -490,6 +492,10 @@ class DatabaseOracle extends DatabaseBase { $val = null; } + if ( $val === 'NULL' ) { + $val = null; + } + if ( $val === null ) { if ( $col_info != false && $col_info->isNullable() == 0 && $col_info->defaultValue() != null ) { $bind .= 'DEFAULT'; @@ -771,15 +777,23 @@ class DatabaseOracle extends DatabaseBase { foreach ( $rows as $row ) { # Delete rows which collide if ( $uniqueIndexes ) { - $condsDelete = array(); - foreach ( $uniqueIndexes as $index ) { - $condsDelete[$index] = $row[$index]; - } - if ( count( $condsDelete ) > 0 ) { - $this->delete( $table, $condsDelete, $fname ); + $deleteConds = array(); + foreach ( $uniqueIndexes as $key=>$index ) { + if ( is_array( $index ) ) { + $deleteConds2 = array(); + foreach ( $index as $col ) { + $deleteConds2[$col] = $row[$col]; + } + $deleteConds[$key] = $this->makeList( $deleteConds2, LIST_AND ); + } else { + $deleteConds[$index] = $row[$index]; + } } + $deleteConds = array( $this->makeList( $deleteConds, LIST_OR ) ); + $this->delete( $table, $deleteConds, $fname ); } + if ( $sequenceData !== false && !isset( $row[$sequenceData['column']] ) ) { $row[$sequenceData['column']] = $this->nextSequenceValue( $sequenceData['sequence'] ); } @@ -1146,28 +1160,41 @@ class DatabaseOracle extends DatabaseBase { return $s; } - function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) { + private function wrapFieldForWhere( $table, &$col, &$val ) { global $wgContLang; + + $col_info = $this->fieldInfoMulti( $table, $col ); + $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; + if ( $col_type == 'CLOB' ) { + $col = 'TO_CHAR(' . $col . ')'; + $val = $wgContLang->checkTitleEncoding( $val ); + } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) { + $val = $wgContLang->checkTitleEncoding( $val ); + } + } - if ($conds != null) { - $conds2 = array(); - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds; - foreach ( $conds as $col => $val ) { - $col_info = $this->fieldInfoMulti( $table, $col ); - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; - if ( $col_type == 'CLOB' ) { - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val ); - } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) { - $conds2[$col] = $wgContLang->checkTitleEncoding( $val ); + private function wrapConditionsForWhere ( $table, $conds, $parentCol = null ) { + $conds2 = array(); + foreach ( $conds as $col => $val ) { + if ( is_array( $val ) ) { + $conds2[$col] = $this->wrapConditionsForWhere ( $table, $val, $col ); + } else { + if ( is_numeric( $col ) && $parentCol != null ) { + $this->wrapFieldForWhere ( $table, $parentCol, $val ); } else { - $conds2[$col] = $val; + $this->wrapFieldForWhere ( $table, $col, $val ); } + $conds2[$col] = $val; } + } + return $conds2; + } - return parent::selectRow( $table, $vars, $conds2, $fname, $options, $join_conds ); - } else { - return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds ); + function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) { + if ( is_array($conds) ) { + $conds = $this->wrapConditionsForWhere( $table, $conds ); } + return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds ); } /** @@ -1214,32 +1241,10 @@ class DatabaseOracle extends DatabaseBase { } public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) { - global $wgContLang; - - if ( $wgContLang != null && $conds != null && $conds != '*' ) { - $conds2 = array(); - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds; - foreach ( $conds as $col => $val ) { - $col_info = $this->fieldInfoMulti( $table, $col ); - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; - if ( $col_type == 'CLOB' ) { - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val ); - } else { - if ( is_array( $val ) ) { - $conds2[$col] = $val; - foreach ( $conds2[$col] as &$val2 ) { - $val2 = $wgContLang->checkTitleEncoding( $val2 ); - } - } else { - $conds2[$col] = $wgContLang->checkTitleEncoding( $val ); - } - } - } - - return parent::delete( $table, $conds2, $fname ); - } else { - return parent::delete( $table, $conds, $fname ); + if ( is_array($conds) ) { + $conds = $this->wrapConditionsForWhere( $table, $conds ); } + return parent::delete( $table, $conds, $fname ); } function update( $table, $values, $conds, $fname = 'DatabaseOracle::update', $options = array() ) { @@ -1262,6 +1267,7 @@ class DatabaseOracle extends DatabaseBase { } if ( $conds != '*' ) { + $conds = $this->wrapConditionsForWhere( $table, $conds ); $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); } |