* Added getInfinity to DatabaseOracle
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Thu, 10 Nov 2011 07:41:12 +0000 (07:41 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Thu, 10 Nov 2011 07:41:12 +0000 (07:41 +0000)
* Block - replaced 'infinity' strings with DB->getInfinity calls
* UploadStash - added sequence value generation for ID

includes/Block.php
includes/api/ApiQueryBlocks.php
includes/db/DatabaseOracle.php
includes/upload/UploadStash.php
tests/phpunit/includes/api/ApiBlockTest.php

index 7aa1bc1..6be0348 100644 (file)
@@ -81,8 +81,8 @@ class Block {
                $this->mAuto = $auto;
                $this->isHardblock( !$anonOnly );
                $this->prevents( 'createaccount', $createAccount );
-               if ( $expiry == 'infinity' || $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
-                       $this->mExpiry = 'infinity';
+               if ( $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
+                       $this->mExpiry = $expiry;
                } else {
                        $this->mExpiry = wfTimestamp( TS_MW, $expiry );
                }
@@ -362,9 +362,8 @@ class Block {
                $this->mId = $row->ipb_id;
 
                // I wish I didn't have to do this
-               $db = wfGetDB( DB_SLAVE );
-               if ( $row->ipb_expiry == $db->getInfinity() ) {
-                       $this->mExpiry = 'infinity';
+               if ( $row->ipb_expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
+                       $this->mExpiry = $row->ipb_expiry;
                } else {
                        $this->mExpiry = wfTimestamp( TS_MW, $row->ipb_expiry );
                }
@@ -653,7 +652,7 @@ class Block {
                $autoblock->mHideName = $this->mHideName;
                $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) );
 
-               if ( $this->mExpiry == 'infinity' ) {
+               if ( $this->mExpiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
                        # Original block was indefinite, start an autoblock now
                        $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
                } else {
index 9a416df..51b9750 100644 (file)
@@ -130,8 +130,8 @@ class ApiQueryBlocks extends ApiQueryBase {
                        $this->addWhereIf( 'ipb_user != 0', isset( $show['account'] ) );
                        $this->addWhereIf( 'ipb_user != 0 OR ipb_range_end > ipb_range_start', isset( $show['!ip'] ) );
                        $this->addWhereIf( 'ipb_user = 0 AND ipb_range_end = ipb_range_start', isset( $show['ip'] ) );
-                       $this->addWhereIf( "ipb_expiry = 'infinity'", isset( $show['!temp'] ) );
-                       $this->addWhereIf( "ipb_expiry != 'infinity'", isset( $show['temp'] ) );
+                       $this->addWhereIf( "ipb_expiry = '".$db->getInfinity()."'", isset( $show['!temp'] ) );
+                       $this->addWhereIf( "ipb_expiry != '".$db->getInfinity()."'", isset( $show['temp'] ) );
                        $this->addWhereIf( "ipb_range_end = ipb_range_start", isset( $show['!range'] ) );
                        $this->addWhereIf( "ipb_range_end > ipb_range_start", isset( $show['range'] ) );
                }
index 5e63767..a5ceceb 100644 (file)
@@ -548,8 +548,9 @@ class DatabaseOracle extends DatabaseBase {
                                        $val = $val->fetch();
                                }
 
+                               // backward compatibility
                                if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
-                                       $val = '31-12-2030 12:00:00.000000';
+                                       $val = $this->getInfinity();
                                }
 
                                $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
@@ -1315,4 +1316,9 @@ class DatabaseOracle extends DatabaseBase {
        public function getSearchEngine() {
                return 'SearchOracle';
        }
+       
+       public function getInfinity() {
+               return '31-12-2030 12:00:00.000000';
+       }
+       
 } // end DatabaseOracle class
index 4fac9a9..217b84d 100644 (file)
@@ -229,6 +229,7 @@ class UploadStash {
                $dbw = $this->repo->getMasterDb();
 
                $this->fileMetadata[$key] = array(
+                       'us_id' => $dbw->nextSequenceValue( 'uploadstash_us_id_seq' ),
                        'us_user' => $this->userId,
                        'us_key' => $key,
                        'us_orig_path' => $path,
index 514da42..514ca85 100644 (file)
@@ -55,7 +55,7 @@ class ApiBlockTest extends ApiTestCase {
 
                $this->assertEquals( 'UTApiBlockee', (string)$block->getTarget() );
                $this->assertEquals( 'Some reason', $block->mReason );
-               $this->assertEquals( 'infinity', $block->mExpiry );
+               $this->assertEquals( $this->db->getInfinity(), $block->mExpiry );
 
        }