http://www.mediawiki.org/wiki/Special:Code/MediaWiki/92480

Revision: 92480
Author:   werdna
Date:     2011-07-18 21:48:56 +0000 (Mon, 18 Jul 2011)
Log Message:
-----------
Block.php fixes: Always store mExpiry as a TS_MW or "infinity". Convert as 
appropriate.

Modified Paths:
--------------
    trunk/phase3/includes/Block.php

Modified: trunk/phase3/includes/Block.php
===================================================================
--- trunk/phase3/includes/Block.php     2011-07-18 21:41:47 UTC (rev 92479)
+++ trunk/phase3/includes/Block.php     2011-07-18 21:48:56 UTC (rev 92480)
@@ -77,7 +77,11 @@
                $this->mAuto = $auto;
                $this->isHardblock( !$anonOnly );
                $this->prevents( 'createaccount', $createAccount );
-               $this->mExpiry = $expiry;
+               if ( $expiry == 'infinity' || $expiry == Block::infinity() ) {
+                       $this->mExpiry = 'infinity';
+               } else {
+                       $this->mExpiry = wfTimestamp( TS_MW, $expiry );
+               }
                $this->isAutoblocking( $enableAutoblock );
                $this->mHideName = $hideName;
                $this->prevents( 'sendemail', $blockEmail );
@@ -342,13 +346,20 @@
        protected function initFromRow( $row ) {
                $this->setTarget( $row->ipb_address );
                $this->setBlocker( User::newFromId( $row->ipb_by ) );
-
+               
                $this->mReason = $row->ipb_reason;
                $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
                $this->mAuto = $row->ipb_auto;
                $this->mHideName = $row->ipb_deleted;
                $this->mId = $row->ipb_id;
-               $this->mExpiry = $row->ipb_expiry;
+               
+               // I wish I didn't have to do this
+               $db = wfGetDB( DB_SLAVE );
+               if ( $row->ipb_expiry == $db->getInfinity() ) {
+                       $this->mExpiry = 'infinity';
+               } else {
+                       $this->mExpiry = wfTimestamp( TS_MW, $row->ipb_expiry );
+               }
 
                $this->isHardblock( !$row->ipb_anon_only );
                $this->isAutoblocking( $row->ipb_enable_autoblock );
@@ -455,7 +466,7 @@
                if( !$db ){
                        $db = wfGetDB( DB_SLAVE );
                }
-               $this->mExpiry = $db->encodeExpiry( $this->mExpiry );
+               $expiry = $db->encodeExpiry( $this->mExpiry );
 
                $a = array(
                        'ipb_address'          => (string)$this->target,
@@ -468,7 +479,7 @@
                        'ipb_anon_only'        => !$this->isHardblock(),
                        'ipb_create_account'   => $this->prevents( 
'createaccount' ),
                        'ipb_enable_autoblock' => $this->isAutoblocking(),
-                       'ipb_expiry'           => $this->mExpiry,
+                       'ipb_expiry'           => $expiry,
                        'ipb_range_start'      => $this->getRangeStart(),
                        'ipb_range_end'        => $this->getRangeEnd(),
                        'ipb_deleted'          => intval( $this->mHideName ), 
// typecast required for SQLite


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to