X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=f97cabce15a2e23b0056f7897478b350d5f5c270;hb=18c60be0d3d871ad146e7a5a9b12a803bb886518;hp=3f0ed4871797abe37ab4d90cafa85aea3194eb83;hpb=ceb415f7edb31fb027f210677361cc422baba5ba;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index 3f0ed48717..f97cabce15 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -35,7 +35,11 @@ class Block $this->mReason = $reason; $this->mTimestamp = wfTimestamp(TS_MW,$timestamp); $this->mAuto = $auto; - $this->mExpiry = wfTimestamp(TS_MW,$expiry); + if( empty( $expiry ) ) { + $this->mExpiry = $expiry; + } else { + $this->mExpiry = wfTimestamp( TS_MW, $expiry ); + } $this->mForUpdate = false; $this->initialiseRange(); @@ -54,10 +58,14 @@ class Block $mUser = $mBy = 0; } - # Get a ban from the DB, with either the given address or the given username + /** + * Get a ban from the DB, with either the given address or the given username + */ function load( $address = '', $user = 0, $killExpired = true ) { + global $wgDBmysql4 ; $fname = 'Block::load'; + wfDebug( "Block::load: '$address', '$user', $killExpired\n" ); $ret = false; $killed = false; @@ -76,7 +84,7 @@ class Block $sql = "SELECT * FROM $ipblocks WHERE ipb_user={$user} $options"; } elseif ($user=="") { $sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) . "' $options"; - } elseif ( $options=='' ) { + } elseif ( $options=='' && $wgDBmysql4 ) { # If there are no optiones (e.g. FOR UPDATE), use a UNION # so that the query can make efficient use of indices $sql = "SELECT * FROM $ipblocks WHERE ipb_address='" . $db->strencode( $address ) . @@ -133,7 +141,9 @@ class Block $this->mBy = $row->ipb_by; $this->mAuto = $row->ipb_auto; $this->mId = $row->ipb_id; - $this->mExpiry = wfTimestamp(TS_MW,$row->ipb_expiry); + $this->mExpiry = $row->ipb_expiry ? + wfTimestamp(TS_MW,$row->ipb_expiry) : + $row->ipb_expiry; $this->initialiseRange(); } @@ -154,7 +164,9 @@ class Block } } - # Callback with a Block object for every block + /** + * Callback with a Block object for every block + */ /*static*/ function enumBlocks( $callback, $tag, $flags = 0 ) { $block = new Block(); @@ -187,6 +199,9 @@ class Block function delete() { $fname = 'Block::delete'; + if (wfReadOnly()) { + return; + } $dbw =& wfGetDB( DB_MASTER ); if ( $this->mAddress == '' ) { @@ -200,6 +215,7 @@ class Block function insert() { + wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" ); $dbw =& wfGetDB( DB_MASTER ); $dbw->insert( 'ipblocks', array( @@ -209,7 +225,9 @@ class Block 'ipb_reason' => $this->mReason, 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp), 'ipb_auto' => $this->mAuto, - 'ipb_expiry' => $dbw->timestamp($this->mExpiry), + 'ipb_expiry' => $this->mExpiry ? + $dbw->timestamp($this->mExpiry) : + $this->mExpiry, ), 'Block::insert' ); @@ -219,19 +237,22 @@ class Block function deleteIfExpired() { if ( $this->isExpired() ) { + wfDebug( "Block::deleteIfExpired() -- deleting\n" ); $this->delete(); return true; } else { + wfDebug( "Block::deleteIfExpired() -- not expired\n" ); return false; } } function isExpired() { + wfDebug( "Block::isExpired() checking current " . wfTimestampNow() . " vs $this->mExpiry\n" ); if ( !$this->mExpiry ) { return false; } else { - return wfTimestamp() > $this->mExpiry; + return wfTimestampNow() > $this->mExpiry; } }