Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -297,28 +297,26 @@ |
298 | 298 | $union_unique = ( preg_match( '/\/\* UNION_UNIQUE \*\/ /', $sql ) != 0 ); |
299 | 299 | // EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing |
300 | 300 | // you have to select data from plan table after explain |
301 | | - $olderr = error_reporting( E_ERROR ); |
302 | 301 | $explain_id = date( 'dmYHis' ); |
303 | | - error_reporting( $olderr ); |
304 | 302 | |
305 | 303 | $sql = preg_replace( '/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR', $sql, 1, $explain_count ); |
306 | 304 | |
307 | 305 | |
308 | | - $olderr = error_reporting( E_ERROR ); |
| 306 | + wfSuppressWarnings(); |
309 | 307 | |
310 | 308 | if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) { |
311 | 309 | $e = oci_error( $this->mConn ); |
312 | 310 | $this->reportQueryError( $e['message'], $e['code'], $sql, __FUNCTION__ ); |
313 | 311 | } |
314 | 312 | |
315 | | - $olderr = error_reporting( E_ERROR ); |
316 | 313 | if ( oci_execute( $stmt, $this->execFlags() ) == false ) { |
317 | 314 | $e = oci_error( $stmt ); |
318 | 315 | if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) { |
319 | 316 | $this->reportQueryError( $e['message'], $e['code'], $sql, __FUNCTION__ ); |
320 | 317 | } |
321 | 318 | } |
322 | | - error_reporting( $olderr ); |
| 319 | + |
| 320 | + wfRestoreWarnings(); |
323 | 321 | |
324 | 322 | if ( $explain_count > 0 ) { |
325 | 323 | return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table WHERE statement_id = \'' . $explain_id . '\'' ); |
— | — | @@ -511,7 +509,8 @@ |
512 | 510 | } |
513 | 511 | } |
514 | 512 | |
515 | | - $olderr = error_reporting( E_ERROR ); |
| 513 | + wfSuppressWarnings(); |
| 514 | + |
516 | 515 | if ( oci_execute( $stmt, OCI_DEFAULT ) === false ) { |
517 | 516 | $e = oci_error( $stmt ); |
518 | 517 | |
— | — | @@ -523,8 +522,9 @@ |
524 | 523 | } else { |
525 | 524 | $this->mAffectedRows = oci_num_rows( $stmt ); |
526 | 525 | } |
527 | | - error_reporting( $olderr ); |
528 | 526 | |
| 527 | + wfRestoreWarnings(); |
| 528 | + |
529 | 529 | if ( isset( $lob ) ) { |
530 | 530 | foreach ( $lob as $lob_i => $lob_v ) { |
531 | 531 | $lob_v->free(); |
— | — | @@ -584,6 +584,13 @@ |
585 | 585 | } |
586 | 586 | |
587 | 587 | function tableName( $name ) { |
| 588 | + if (is_array($name)) { |
| 589 | + foreach($name as &$single_name) { |
| 590 | + $single_name = $this->tableName($single_name); |
| 591 | + } |
| 592 | + return $name; |
| 593 | + } |
| 594 | + |
588 | 595 | global $wgSharedDB, $wgSharedPrefix, $wgSharedTables; |
589 | 596 | /* |
590 | 597 | Replace reserved words with better ones |
— | — | @@ -606,7 +613,6 @@ |
607 | 614 | if ( $name[0] == '"' && substr( $name, - 1, 1 ) == '"' ) { |
608 | 615 | return $name; |
609 | 616 | } |
610 | | - |
611 | 617 | if ( preg_match( '/(^|\s)(DISTINCT|JOIN|ON|AS)(\s|$)/i', $name ) !== 0 ) { |
612 | 618 | return $name; |
613 | 619 | } |
— | — | @@ -831,25 +837,37 @@ |
832 | 838 | * based on prebuilt table to simulate MySQL field info and keep query speed minimal |
833 | 839 | */ |
834 | 840 | function fieldExists( $table, $field, $fname = 'DatabaseOracle::fieldExists' ) { |
835 | | - $table = trim( $table, '"' ); |
836 | | - |
837 | | - if (isset($this->mFieldInfoCache["$table.$field"])) { |
838 | | - return true; |
839 | | - } elseif ( !isset( $this->fieldInfo_stmt ) ) { |
840 | | - $this->fieldInfo_stmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)' ); |
| 841 | + $tableWhere = ''; |
| 842 | + if (is_array($table)) { |
| 843 | + $tableWhere = 'IN ('; |
| 844 | + foreach($table as &$singleTable) { |
| 845 | + $singleTable = trim( $singleTable, '"' ); |
| 846 | + if (isset($this->mFieldInfoCache["$singleTable.$field"])) { |
| 847 | + return $this->mFieldInfoCache["$singleTable.$field"]; |
| 848 | + } |
| 849 | + $tableWhere .= '\''.$singleTable.'\','; |
| 850 | + } |
| 851 | + $tableWhere = rtrim($tableWhere, ',').')'; |
| 852 | + } else { |
| 853 | + $table = trim( $table, '"' ); |
| 854 | + if (isset($this->mFieldInfoCache["$table.$field"])) { |
| 855 | + return $this->mFieldInfoCache["$table.$field"]; |
| 856 | + } |
| 857 | + $tableWhere = '= upper(\''.$table.'\')'; |
841 | 858 | } |
| 859 | + |
| 860 | + $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = UPPER(\''.$field.'\')' ); |
842 | 861 | |
843 | | - oci_bind_by_name( $this->fieldInfo_stmt, ':tab', trim( $table, '"' ) ); |
844 | | - oci_bind_by_name( $this->fieldInfo_stmt, ':col', $field ); |
845 | | - |
846 | | - if ( oci_execute( $this->fieldInfo_stmt, OCI_DEFAULT ) === false ) { |
847 | | - $e = oci_error( $this->fieldInfo_stmt ); |
| 862 | + if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) { |
| 863 | + $e = oci_error( $fieldInfoStmt ); |
848 | 864 | $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ ); |
849 | 865 | return false; |
850 | 866 | } |
851 | | - $res = new ORAResult( $this, $this->fieldInfo_stmt ); |
| 867 | + $res = new ORAResult( $this, $fieldInfoStmt ); |
852 | 868 | if ($res->numRows() != 0) { |
853 | | - $this->mFieldInfoCache["$table.$field"] = new ORAField( $res->fetchRow() ); |
| 869 | + $fieldInfoTemp = new ORAField( $res->fetchRow() ); |
| 870 | + $table = $fieldInfoTemp->tableName(); |
| 871 | + $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp; |
854 | 872 | return true; |
855 | 873 | } else { |
856 | 874 | return false; |
— | — | @@ -857,25 +875,37 @@ |
858 | 876 | } |
859 | 877 | |
860 | 878 | function fieldInfo( $table, $field ) { |
861 | | - $table = trim( $table, '"' ); |
862 | | - |
863 | | - if (isset($this->mFieldInfoCache["$table.$field"])) { |
864 | | - return $this->mFieldInfoCache["$table.$field"]; |
865 | | - } elseif ( !isset( $this->fieldInfo_stmt ) ) { |
866 | | - $this->fieldInfo_stmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)' ); |
| 879 | + $tableWhere = ''; |
| 880 | + if (is_array($table)) { |
| 881 | + $tableWhere = 'IN ('; |
| 882 | + foreach($table as &$singleTable) { |
| 883 | + $singleTable = trim( $singleTable, '"' ); |
| 884 | + if (isset($this->mFieldInfoCache["$singleTable.$field"])) { |
| 885 | + return $this->mFieldInfoCache["$singleTable.$field"]; |
| 886 | + } |
| 887 | + $tableWhere .= '\''.$singleTable.'\','; |
| 888 | + } |
| 889 | + $tableWhere = rtrim($tableWhere, ',').')'; |
| 890 | + } else { |
| 891 | + $table = trim( $table, '"' ); |
| 892 | + if (isset($this->mFieldInfoCache["$table.$field"])) { |
| 893 | + return $this->mFieldInfoCache["$table.$field"]; |
| 894 | + } |
| 895 | + $tableWhere = '= upper(\''.$table.'\')'; |
867 | 896 | } |
| 897 | + |
| 898 | + $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = UPPER(\''.$field.'\')' ); |
868 | 899 | |
869 | | - oci_bind_by_name( $this->fieldInfo_stmt, ':tab', $table ); |
870 | | - oci_bind_by_name( $this->fieldInfo_stmt, ':col', $field ); |
871 | | - |
872 | | - if ( oci_execute( $this->fieldInfo_stmt, OCI_DEFAULT ) === false ) { |
873 | | - $e = oci_error( $this->fieldInfo_stmt ); |
| 900 | + if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) { |
| 901 | + $e = oci_error( $fieldInfoStmt ); |
874 | 902 | $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ ); |
875 | 903 | return false; |
876 | 904 | } |
877 | | - $res = new ORAResult( $this, $this->fieldInfo_stmt ); |
878 | | - $this->mFieldInfoCache["$table.$field"] = new ORAField( $res->fetchRow() ); |
879 | | - return $this->mFieldInfoCache["$table.$field"]; |
| 905 | + $res = new ORAResult( $this, $fieldInfoStmt ); |
| 906 | + $fieldInfoTemp = new ORAField( $res->fetchRow() ); |
| 907 | + $table = $fieldInfoTemp->tableName(); |
| 908 | + $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp; |
| 909 | + return $fieldInfoTemp; |
880 | 910 | } |
881 | 911 | |
882 | 912 | function begin( $fname = '' ) { |
— | — | @@ -1015,6 +1045,7 @@ |
1016 | 1046 | global $wgLang; |
1017 | 1047 | |
1018 | 1048 | $conds2 = array(); |
| 1049 | + $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds; |
1019 | 1050 | foreach ( $conds as $col => $val ) { |
1020 | 1051 | $col_type = $this->fieldInfo( $this->tableName( $table ), $col )->type(); |
1021 | 1052 | if ( $col_type == 'CLOB' ) { |
— | — | @@ -1085,6 +1116,7 @@ |
1086 | 1117 | |
1087 | 1118 | if ( $wgLang != null ) { |
1088 | 1119 | $conds2 = array(); |
| 1120 | + $conds = ($conds != null && !is_array($conds)) ? array($conds) : $conds; |
1089 | 1121 | foreach ( $conds as $col => $val ) { |
1090 | 1122 | $col_type = $this->fieldInfo( $this->tableName( $table ), $col )->type(); |
1091 | 1123 | if ( $col_type == 'CLOB' ) { |
Index: trunk/phase3/config/Installer.php |
— | — | @@ -1009,9 +1009,9 @@ |
1010 | 1010 | } elseif ( $conf->DBtype == 'oracle' ) { |
1011 | 1011 | echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>"; |
1012 | 1012 | $old_error_level = error_reporting(); |
1013 | | - error_reporting($old_error_level & ~E_WARNING); //disable E_WARNING for test connect (oci returns login denied as warning) |
| 1013 | + wfSuppressWarnings(); |
1014 | 1014 | $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1); |
1015 | | - error_reporting($old_error_level); |
| 1015 | + wfRestoreWarnings(); |
1016 | 1016 | if (!$wgDatabase->isOpen()) { |
1017 | 1017 | $ok = true; |
1018 | 1018 | echo "<li>Connect failed.</li>"; |