r92480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92479‎ | r92480 | r92481 >
Date:21:48, 18 July 2011
Author:werdna
Status:resolved
Tags:
Comment:
Block.php fixes: Always store mExpiry as a TS_MW or "infinity". Convert as appropriate.
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Block.php
@@ -77,7 +77,11 @@
7878 $this->mAuto = $auto;
7979 $this->isHardblock( !$anonOnly );
8080 $this->prevents( 'createaccount', $createAccount );
81 - $this->mExpiry = $expiry;
 81+ if ( $expiry == 'infinity' || $expiry == Block::infinity() ) {
 82+ $this->mExpiry = 'infinity';
 83+ } else {
 84+ $this->mExpiry = wfTimestamp( TS_MW, $expiry );
 85+ }
8286 $this->isAutoblocking( $enableAutoblock );
8387 $this->mHideName = $hideName;
8488 $this->prevents( 'sendemail', $blockEmail );
@@ -342,13 +346,20 @@
343347 protected function initFromRow( $row ) {
344348 $this->setTarget( $row->ipb_address );
345349 $this->setBlocker( User::newFromId( $row->ipb_by ) );
346 -
 350+
347351 $this->mReason = $row->ipb_reason;
348352 $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
349353 $this->mAuto = $row->ipb_auto;
350354 $this->mHideName = $row->ipb_deleted;
351355 $this->mId = $row->ipb_id;
352 - $this->mExpiry = $row->ipb_expiry;
 356+
 357+ // I wish I didn't have to do this
 358+ $db = wfGetDB( DB_SLAVE );
 359+ if ( $row->ipb_expiry == $db->getInfinity() ) {
 360+ $this->mExpiry = 'infinity';
 361+ } else {
 362+ $this->mExpiry = wfTimestamp( TS_MW, $row->ipb_expiry );
 363+ }
353364
354365 $this->isHardblock( !$row->ipb_anon_only );
355366 $this->isAutoblocking( $row->ipb_enable_autoblock );
@@ -455,7 +466,7 @@
456467 if( !$db ){
457468 $db = wfGetDB( DB_SLAVE );
458469 }
459 - $this->mExpiry = $db->encodeExpiry( $this->mExpiry );
 470+ $expiry = $db->encodeExpiry( $this->mExpiry );
460471
461472 $a = array(
462473 'ipb_address' => (string)$this->target,
@@ -468,7 +479,7 @@
469480 'ipb_anon_only' => !$this->isHardblock(),
470481 'ipb_create_account' => $this->prevents( 'createaccount' ),
471482 'ipb_enable_autoblock' => $this->isAutoblocking(),
472 - 'ipb_expiry' => $this->mExpiry,
 483+ 'ipb_expiry' => $expiry,
473484 'ipb_range_start' => $this->getRangeStart(),
474485 'ipb_range_end' => $this->getRangeEnd(),
475486 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite

Follow-up revisions

RevisionCommit summaryAuthorDate
r92482Fix autoblocks in r92480werdna21:56, 18 July 2011
r92485Fix autoblocks in r92480 r92482 -- modified the wrong halfwerdna22:02, 18 July 2011
r92505MFT r92477, r92480, r92481, r92482, r92484, r9485, r92486...reedy23:14, 18 July 2011

Status & tagging log