r58559 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58558‎ | r58559 | r58560 >
Date:19:09, 4 November 2009
Author:freakolowsky
Status:resolved (Comments)
Tags:
Comment:
Fixed some Oracle-specific installer and Strict Standards issues
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/maintenance/ora/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/ora/tables.sql
@@ -659,7 +659,7 @@
660660 /*$mw$*/
661661
662662 /*$mw$*/
663 -CREATE OR REPLACE TYPE GET_OUTPUT_TYPE AS TABLE OF VARCHAR2(255);
 663+CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
664664 /*$mw$*/
665665
666666 /*$mw$*/
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -208,8 +208,7 @@
209209 return true;
210210 }
211211
212 - static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
213 - $failFunction = false, $flags = 0)
 212+ static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 )
214213 {
215214 return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags );
216215 }
@@ -289,7 +288,9 @@
290289 $union_unique = (preg_match('/\/\* UNION_UNIQUE \*\/ /', $sql) != 0);
291290 //EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
292291 //you have to select data from plan table after explain
 292+ $olderr = error_reporting(E_ERROR);
293293 $explain_id = date('dmYHis');
 294+ error_reporting($olderr);
294295 $sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \''.$explain_id.'\' FOR', $sql, 1, $explain_count);
295296
296297
@@ -446,33 +447,30 @@
447448 $first = true;
448449 foreach ($row as $col => $val) {
449450 if ($first)
450 - $sql .= ':'.$col;
 451+ $sql .= $val !== NULL ? ':'.$col : 'NULL';
451452 else
452 - $sql.= ', :'.$col;
 453+ $sql .= $val !== NULL ? ', :'.$col : ', NULL';
453454
454455 $first = false;
455456 }
456457 $sql .= ')';
457458
458 - $stmt = oci_parse($this->mConn, $sql);
459 - foreach ($row as $col => $val) {
460 - if (!is_object($val)) {
461 - if (oci_bind_by_name($stmt, ":$col", $row[$col]) === false)
462 - $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
463 - }
464 - }
465459
466460 $stmt = oci_parse($this->mConn, $sql);
467 - foreach ($row as $col => $val) {
 461+ foreach ($row as $col => &$val) {
468462 $col_type=$this->fieldInfo($this->tableName($table), $col)->type();
469 - if ($col_type != 'BLOB' && $col_type != 'CLOB') {
 463+
 464+ if ($val === NULL) {
 465+ // do nothing ... null was inserted in statement creation
 466+ } elseif ($col_type != 'BLOB' && $col_type != 'CLOB') {
470467 if (is_object($val))
471468 $val = $val->getData();
472 -
 469+
473470 if (preg_match('/^timestamp.*/i', $col_type) == 1 && strtolower($val) == 'infinity')
474471 $val = '31-12-2030 12:00:00.000000';
475472
476 - if (oci_bind_by_name($stmt, ":$col", $wgLang->checkTitleEncoding($val)) === false)
 473+ $val = $wgLang->checkTitleEncoding($val);
 474+ if (oci_bind_by_name($stmt, ":$col", $val) === false)
477475 $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__);
478476 } else {
479477 if (($lob[$col] = oci_new_descriptor($this->mConn, OCI_D_LOB)) === false) {
@@ -489,7 +487,7 @@
490488 }
491489 }
492490 }
493 -
 491+
494492 $olderr = error_reporting(E_ERROR);
495493 if (oci_execute($stmt, OCI_DEFAULT) === false) {
496494 $e = oci_error($stmt);
@@ -720,14 +718,14 @@
721719 return $size;
722720 }
723721
724 - function limitResult($sql, $limit, $offset) {
 722+ function limitResult( $sql, $limit, $offset=false ) {
725723 if ($offset === false)
726724 $offset = 0;
727725 return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
728726 }
729727
730728
731 - function unionQueries($sqls, $all = false) {
 729+ function unionQueries($sqls, $all) {
732730 $glue = ' UNION ALL ';
733731 return 'SELECT * '.($all?'':'/* UNION_UNIQUE */ ').'FROM ('.implode( $glue, $sqls ).')' ;
734732 }
@@ -801,7 +799,7 @@
802800 * Query whether a given column exists in the mediawiki schema
803801 * based on prebuilt table to simulate MySQL field info and keep query speed minimal
804802 */
805 - function fieldExists( $table, $field ) {
 803+ function fieldExists( $table, $field, $fname = 'DatabaseOracle::fieldExists' ) {
806804 if (!isset($this->fieldInfo_stmt))
807805 $this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
808806
@@ -821,7 +819,8 @@
822820 if (!isset($this->fieldInfo_stmt))
823821 $this->fieldInfo_stmt = oci_parse($this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
824822
825 - oci_bind_by_name($this->fieldInfo_stmt, ':tab', trim($table, '"'));
 823+ $table = trim($table, '"');
 824+ oci_bind_by_name($this->fieldInfo_stmt, ':tab', $table);
826825 oci_bind_by_name($this->fieldInfo_stmt, ':col', $field);
827826
828827 if (oci_execute($this->fieldInfo_stmt, OCI_DEFAULT) === false) {
Index: trunk/phase3/config/Installer.php
@@ -106,7 +106,7 @@
107107 'havedriver' => 0,
108108 'compile' => 'oci8',
109109 'bgcolor' => '#ffeba1',
110 - 'rootuser' => '',
 110+ 'rootuser' => 'sys',
111111 'serverless' => false
112112 );
113113
@@ -1027,7 +1027,10 @@
10281028 echo "ok</li>\n";
10291029 } elseif ( $conf->DBtype == 'oracle' ) {
10301030 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
 1031+ $old_error_level = error_reporting();
 1032+ error_reporting($old_error_level & ~E_WARNING); //disable E_WARNING for test connect (oci returns login denied as warning)
10311033 $wgDatabase = $dbc->newFromParams('DUMMY', $wgDBuser, $wgDBpassword, $wgDBname, 1);
 1034+ error_reporting($old_error_level);
10321035 if (!$wgDatabase->isOpen()) {
10331036 $ok = true;
10341037 echo "<li>Connect failed.</li>";

Follow-up revisions

RevisionCommit summaryAuthorDate
r60825* Fixed the issue of all date functions throwing E_STRICT on their first call...tstarling01:48, 8 January 2010
r61179Fixed error suppressing suggested in r58559 by Tim. Also fixed some warnings ...freakolowsky20:42, 17 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   00:10, 11 January 2010

We have wfSuppressWarnings() and wfRestoreWarnings() which should be used instead of error_reporting(). But note that it's not necessary to wrap them around date() anymore since r60825.

#Comment by Siebrand (talk | contribs)   16:32, 17 January 2010

Were Tim's comments addressed, and if so, in which rev?

#Comment by Freakolowsky (talk | contribs)   20:49, 17 January 2010

sry for delay ... r61179.

Status & tagging log