From: Jure Kajzer Date: Mon, 9 Nov 2009 14:34:03 +0000 (+0000) Subject: Fixed parserTests to work with Oracle (added Anonymous user 0 to fix FK violations... X-Git-Tag: 1.31.0-rc.0~38866 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=17821ff2f13e5f79d3a3aa1a2204a93f9a880d40;p=lhc%2Fweb%2Fwiklou.git Fixed parserTests to work with Oracle (added Anonymous user 0 to fix FK violations). Fixed a few bugs identified by parserTests fails. --- diff --git a/includes/JobQueue.php b/includes/JobQueue.php index afa757d752..a6e6d8ce56 100644 --- a/includes/JobQueue.php +++ b/includes/JobQueue.php @@ -267,12 +267,13 @@ abstract class Job { return; } } - $fields['job_id'] = $dbw->nextSequenceValue( 'job_job_id_seq' ); $dbw->insert( 'job', $fields, __METHOD__ ); } protected function insertFields() { + $dbw = wfGetDB( DB_MASTER ); return array( + 'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ), 'job_cmd' => $this->command, 'job_namespace' => $this->title->getNamespace(), 'job_title' => $this->title->getDBkey(), diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 283421560b..0bafb2ba5b 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -426,7 +426,8 @@ class DatabaseOracle extends DatabaseBase { if (!is_array(reset($a))) { $a = array($a); } - foreach ($a as $row) { + + foreach ($a as &$row) { $this->insertOneRow($table, $row, $fname); } $retVal = true; @@ -470,7 +471,7 @@ class DatabaseOracle extends DatabaseBase { if (preg_match('/^timestamp.*/i', $col_type) == 1 && strtolower($val) == 'infinity') $val = '31-12-2030 12:00:00.000000'; - $val = $wgLang->checkTitleEncoding($val); + $val = ($wgLang != null) ? $wgLang->checkTitleEncoding($val) : $val; if (oci_bind_by_name($stmt, ":$col", $val) === false) $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__); } else { @@ -1049,16 +1050,18 @@ class DatabaseOracle extends DatabaseBase { public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) { global $wgLang; - $conds2 = array(); - foreach($conds as $col=>$val) { - $col_type=$this->fieldInfo($this->tableName($table), $col)->type(); - if ($col_type == 'CLOB') - $conds2['TO_CHAR('.$col.')'] = $wgLang->checkTitleEncoding($val); - else - $conds2[$col] = $wgLang->checkTitleEncoding($val); - } - - return parent::delete( $table, $conds2, $fname ); + if ($wgLang != null) { + $conds2 = array(); + foreach($conds as $col=>$val) { + $col_type=$this->fieldInfo($this->tableName($table), $col)->type(); + if ($col_type == 'CLOB') + $conds2['TO_CHAR('.$col.')'] = $wgLang->checkTitleEncoding($val); + else + $conds2[$col] = $wgLang->checkTitleEncoding($val); + } + + return parent::delete( $table, $conds2, $fname ); + } else return parent::delete( $table, $conds, $fname ); } function bitNot($field) { diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index c357f88da9..7d5ba6488a 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -783,6 +783,13 @@ class ParserTest { 'iw_url' => 'http://ru.wikipedia.org/wiki/$1', 'iw_local' => 1 ), ) ); + + + #Anonymous user + $db->insert( 'user', array( + 'user_id' => 0, + 'user_name' => 'Anonymous') ); + # Hack-on-Hack: Insert a test user to be able to insert an image $db->insert( 'user', array( 'user_id' => 1,