Fixed some Oracle-specific installer and Strict Standards issues
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Wed, 4 Nov 2009 19:09:11 +0000 (19:09 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Wed, 4 Nov 2009 19:09:11 +0000 (19:09 +0000)
config/Installer.php
includes/db/DatabaseOracle.php
maintenance/ora/tables.sql

index 90c2938..9e7e188 100644 (file)
@@ -106,7 +106,7 @@ $ourdb['oracle'] = array(
        'havedriver' => 0,
        'compile'    => 'oci8',
        'bgcolor'    => '#ffeba1',
-       'rootuser'   => '',
+       'rootuser'   => 'sys',
        'serverless' => false
 );
 
@@ -1027,7 +1027,10 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        echo "ok</li>\n";
                } elseif ( $conf->DBtype == 'oracle' ) {
                        echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
+                       $old_error_level = error_reporting();
+                       error_reporting($old_error_level & ~E_WARNING); //disable E_WARNING for test connect (oci returns login denied as warning)
                        $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
+                       error_reporting($old_error_level);
                        if (!$wgDatabase->isOpen()) {
                                $ok = true;
                                echo "<li>Connect failed.</li>";
index e90d6fc..f1d90ac 100644 (file)
@@ -208,8 +208,7 @@ class DatabaseOracle extends DatabaseBase {
                return true;
        }
 
-       static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
-               $failFunction = false, $flags = 0)
+       static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 )
        {
                return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags );
        }
@@ -289,7 +288,9 @@ class DatabaseOracle extends DatabaseBase {
                $union_unique = (preg_match('/\/\* UNION_UNIQUE \*\/ /', $sql) != 0);
                //EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
                //you have to select data from plan table after explain
+               $olderr = error_reporting(E_ERROR);
                $explain_id = date('dmYHis');
+               error_reporting($olderr);
                $sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \''.$explain_id.'\' FOR', $sql, 1, $explain_count);
                        
                
@@ -446,33 +447,30 @@ class DatabaseOracle extends DatabaseBase {
                $first = true;
                foreach ($row as $col => $val) {
                        if ($first)
-                               $sql .= ':'.$col;
+                               $sql .= $val !== NULL ? ':'.$col : 'NULL';
                        else
-                               $sql.= ', :'.$col;
+                               $sql .= $val !== NULL ? ', :'.$col : ', NULL';
                        
                        $first = false;
                }
                $sql .= ')';
 
-               $stmt = oci_parse($this->mConn, $sql);
-               foreach ($row as $col => $val) {
-                       if (!is_object($val)) {
-                               if (oci_bind_by_name($stmt, ":$col", $row[$col]) === false)
-                                       $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
-                       }
-               }
                
                $stmt = oci_parse($this->mConn, $sql);
-               foreach ($row as $col => $val) {
+               foreach ($row as $col => &$val) {
                        $col_type=$this->fieldInfo($this->tableName($table), $col)->type();
-                       if ($col_type != 'BLOB' && $col_type != 'CLOB') {
+                       
+                       if ($val === NULL) {
+                               // do nothing ... null was inserted in statement creation
+                       } elseif ($col_type != 'BLOB' && $col_type != 'CLOB') {
                                if (is_object($val))
                                        $val = $val->getData();
-                               
+                       
                                if (preg_match('/^timestamp.*/i', $col_type) == 1 && strtolower($val) == 'infinity') 
                                        $val = '31-12-2030 12:00:00.000000';
                                
-                               if (oci_bind_by_name($stmt, ":$col", $wgLang->checkTitleEncoding($val)) === false)
+                               $val = $wgLang->checkTitleEncoding($val);
+                               if (oci_bind_by_name($stmt, ":$col", $val) === false)
                                        $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
                        } else {
                                if (($lob[$col] = oci_new_descriptor($this->mConn, OCI_D_LOB)) === false) {
@@ -489,7 +487,7 @@ class DatabaseOracle extends DatabaseBase {
                                }
                        }
                }
-               
+
                $olderr = error_reporting(E_ERROR);
                if (oci_execute($stmt, OCI_DEFAULT) === false) {
                        $e = oci_error($stmt);
@@ -720,14 +718,14 @@ class DatabaseOracle extends DatabaseBase {
                return $size;
        }
 
-       function limitResult($sql, $limit, $offset) {
+       function limitResult( $sql, $limit, $offset=false ) {
                if ($offset === false)
                        $offset = 0;
                return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
        }
 
 
-       function unionQueries($sqls, $all = false) {
+       function unionQueries($sqls, $all) {
                $glue = ' UNION ALL ';
                return 'SELECT * '.($all?'':'/* UNION_UNIQUE */ ').'FROM ('.implode( $glue, $sqls ).')' ;
        }
@@ -801,7 +799,7 @@ class DatabaseOracle extends DatabaseBase {
         * Query whether a given column exists in the mediawiki schema
         * based on prebuilt table to simulate MySQL field info and keep query speed minimal
         */
-       function fieldExists( $table, $field ) {
+       function fieldExists( $table, $field, $fname = 'DatabaseOracle::fieldExists' ) {
                if (!isset($this->fieldInfo_stmt))
                        $this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
 
@@ -821,7 +819,8 @@ class DatabaseOracle extends DatabaseBase {
                if (!isset($this->fieldInfo_stmt))
                        $this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
 
-               oci_bind_by_name($this->fieldInfo_stmt, ':tab', trim($table, '"'));
+               $table = trim($table, '"');
+               oci_bind_by_name($this->fieldInfo_stmt, ':tab', $table);
                oci_bind_by_name($this->fieldInfo_stmt, ':col', $field);
 
                if (oci_execute($this->fieldInfo_stmt, OCI_DEFAULT) === false) {
index 9b08d00..d325033 100644 (file)
@@ -659,7 +659,7 @@ END;
 /*$mw$*/
 
 /*$mw$*/
-CREATE OR REPLACE TYPE GET_OUTPUT_TYPE AS TABLE OF VARCHAR2(255);
+CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
 /*$mw$*/
 
 /*$mw$*/