From: Jure Kajzer Date: Thu, 10 Nov 2011 07:41:12 +0000 (+0000) Subject: * Added getInfinity to DatabaseOracle X-Git-Tag: 1.31.0-rc.0~26601 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=be3bbfc539d8aacccac7adf8c1d2537db8c75c49;p=lhc%2Fweb%2Fwiklou.git * Added getInfinity to DatabaseOracle * Block - replaced 'infinity' strings with DB->getInfinity calls * UploadStash - added sequence value generation for ID --- diff --git a/includes/Block.php b/includes/Block.php index 7aa1bc1dc8..6be0348d31 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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 { diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 9a416df93a..51b97506df 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -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'] ) ); } diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 5e637677ee..a5ceceb94e 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -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 diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 4fac9a960c..217b84dc92 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -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, diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index 514da42120..514ca852da 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -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 ); }