Fixed parserTests to work with Oracle (added Anonymous user 0 to fix FK violations...
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 9 Nov 2009 14:34:03 +0000 (14:34 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 9 Nov 2009 14:34:03 +0000 (14:34 +0000)
includes/JobQueue.php
includes/db/DatabaseOracle.php
maintenance/parserTests.inc

index afa757d..a6e6d8c 100644 (file)
@@ -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(),
index 2834215..0bafb2b 100644 (file)
@@ -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) {
index c357f88..7d5ba64 100644 (file)
@@ -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,