Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -733,15 +733,23 @@ |
734 | 734 | foreach ( $rows as $row ) { |
735 | 735 | # Delete rows which collide |
736 | 736 | if ( $uniqueIndexes ) { |
737 | | - $condsDelete = array(); |
738 | | - foreach ( $uniqueIndexes as $index ) { |
739 | | - $condsDelete[$index] = $row[$index]; |
| 737 | + $deleteConds = array(); |
| 738 | + foreach ( $uniqueIndexes as $key=>$index ) { |
| 739 | + if ( is_array( $index ) ) { |
| 740 | + $deleteConds2 = array(); |
| 741 | + foreach ( $index as $col ) { |
| 742 | + $deleteConds2[$col] = $row[$col]; |
| 743 | + } |
| 744 | + $deleteConds[$key] = $this->makeList( $deleteConds2, LIST_AND ); |
| 745 | + } else { |
| 746 | + $deleteConds[$index] = $row[$index]; |
| 747 | + } |
740 | 748 | } |
741 | | - if ( count( $condsDelete ) > 0 ) { |
742 | | - $this->delete( $table, $condsDelete, $fname ); |
743 | | - } |
| 749 | + $deleteConds = array( $this->makeList( $deleteConds, LIST_OR ) ); |
| 750 | + $this->delete( $table, $deleteConds, $fname ); |
744 | 751 | } |
745 | 752 | |
| 753 | + |
746 | 754 | if ( $sequenceData !== false && !isset( $row[$sequenceData['column']] ) ) { |
747 | 755 | $row[$sequenceData['column']] = $this->nextSequenceValue( $sequenceData['sequence'] ); |
748 | 756 | } |
— | — | @@ -1143,28 +1151,41 @@ |
1144 | 1152 | return strpos($s, '/*Q*/') !== FALSE; |
1145 | 1153 | } |
1146 | 1154 | |
1147 | | - function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) { |
| 1155 | + private function wrapFieldForWhere( $table, &$col, &$val ) { |
1148 | 1156 | global $wgContLang; |
| 1157 | + |
| 1158 | + $col_info = $this->fieldInfoMulti( $table, $col ); |
| 1159 | + $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
| 1160 | + if ( $col_type == 'CLOB' ) { |
| 1161 | + $col = 'TO_CHAR(' . $col . ')'; |
| 1162 | + $val = $wgContLang->checkTitleEncoding( $val ); |
| 1163 | + } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) { |
| 1164 | + $val = $wgContLang->checkTitleEncoding( $val ); |
| 1165 | + } |
| 1166 | + } |
1149 | 1167 | |
1150 | | - if ($conds != null) { |
1151 | | - $conds2 = array(); |
1152 | | - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds; |
1153 | | - foreach ( $conds as $col => $val ) { |
1154 | | - $col_info = $this->fieldInfoMulti( $table, $col ); |
1155 | | - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
1156 | | - if ( $col_type == 'CLOB' ) { |
1157 | | - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val ); |
1158 | | - } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) { |
1159 | | - $conds2[$col] = $wgContLang->checkTitleEncoding( $val ); |
| 1168 | + private function wrapConditionsForWhere ( $table, $conds, $parentCol = null ) { |
| 1169 | + $conds2 = array(); |
| 1170 | + foreach ( $conds as $col => $val ) { |
| 1171 | + if ( is_array( $val ) ) { |
| 1172 | + $conds2[$col] = $this->wrapConditionsForWhere ( $table, $val, $col ); |
| 1173 | + } else { |
| 1174 | + if ( is_numeric( $col ) && $parentCol != null ) { |
| 1175 | + $this->wrapFieldForWhere ( $table, $parentCol, $val ); |
1160 | 1176 | } else { |
1161 | | - $conds2[$col] = $val; |
| 1177 | + $this->wrapFieldForWhere ( $table, $col, $val ); |
1162 | 1178 | } |
| 1179 | + $conds2[$col] = $val; |
1163 | 1180 | } |
| 1181 | + } |
| 1182 | + return $conds2; |
| 1183 | + } |
1164 | 1184 | |
1165 | | - return parent::selectRow( $table, $vars, $conds2, $fname, $options, $join_conds ); |
1166 | | - } else { |
1167 | | - return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds ); |
| 1185 | + function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) { |
| 1186 | + if ( is_array($conds) ) { |
| 1187 | + $conds = $this->wrapConditionsForWhere( $table, $conds ); |
1168 | 1188 | } |
| 1189 | + return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds ); |
1169 | 1190 | } |
1170 | 1191 | |
1171 | 1192 | /** |
— | — | @@ -1211,32 +1232,10 @@ |
1212 | 1233 | } |
1213 | 1234 | |
1214 | 1235 | public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) { |
1215 | | - global $wgContLang; |
1216 | | - |
1217 | | - if ( $wgContLang != null && $conds != null && $conds != '*' ) { |
1218 | | - $conds2 = array(); |
1219 | | - $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds; |
1220 | | - foreach ( $conds as $col => $val ) { |
1221 | | - $col_info = $this->fieldInfoMulti( $table, $col ); |
1222 | | - $col_type = $col_info != false ? $col_info->type() : 'CONSTANT'; |
1223 | | - if ( $col_type == 'CLOB' ) { |
1224 | | - $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val ); |
1225 | | - } else { |
1226 | | - if ( is_array( $val ) ) { |
1227 | | - $conds2[$col] = $val; |
1228 | | - foreach ( $conds2[$col] as &$val2 ) { |
1229 | | - $val2 = $wgContLang->checkTitleEncoding( $val2 ); |
1230 | | - } |
1231 | | - } else { |
1232 | | - $conds2[$col] = $wgContLang->checkTitleEncoding( $val ); |
1233 | | - } |
1234 | | - } |
1235 | | - } |
1236 | | - |
1237 | | - return parent::delete( $table, $conds2, $fname ); |
1238 | | - } else { |
1239 | | - return parent::delete( $table, $conds, $fname ); |
| 1236 | + if ( is_array($conds) ) { |
| 1237 | + $conds = $this->wrapConditionsForWhere( $table, $conds ); |
1240 | 1238 | } |
| 1239 | + return parent::delete( $table, $conds, $fname ); |
1241 | 1240 | } |
1242 | 1241 | |
1243 | 1242 | function update( $table, $values, $conds, $fname = 'DatabaseOracle::update', $options = array() ) { |
— | — | @@ -1259,6 +1258,7 @@ |
1260 | 1259 | } |
1261 | 1260 | |
1262 | 1261 | if ( $conds != '*' ) { |
| 1262 | + $conds = $this->wrapConditionsForWhere( $table, $conds ); |
1263 | 1263 | $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); |
1264 | 1264 | } |
1265 | 1265 | |