From: Aaron Schulz Date: Sat, 18 Jun 2011 00:29:32 +0000 (+0000) Subject: Tweaked comments and code in confusing spot of doAutoblock() X-Git-Tag: 1.31.0-rc.0~29452 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=66894363d8468bdb95e6627600a25fc075aeef14;p=lhc%2Fweb%2Fwiklou.git Tweaked comments and code in confusing spot of doAutoblock() --- diff --git a/includes/Block.php b/includes/Block.php index 5afe5c55a6..cadeabd23b 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -579,35 +579,35 @@ class Block { return false; } - # Check for presence on the autoblock whitelist + # Check for presence on the autoblock whitelist. if ( self::isWhitelistedFromAutoblocks( $autoblockIP ) ) { return false; } - # # Allow hooks to cancel the autoblock. + # Allow hooks to cancel the autoblock. if ( !wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) { wfDebug( "Autoblock aborted by hook.\n" ); return false; } - # It's okay to autoblock. Go ahead and create/insert the block. + # It's okay to autoblock. Go ahead and insert/update the block... + # Do not add a *new* block if the IP is already blocked. $ipblock = Block::newFromTarget( $autoblockIP ); if ( $ipblock ) { - # If the user is already blocked. Then check if the autoblock would - # exceed the user block. If it would exceed, then do nothing, else - # prolong block time - if ( $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) + # Check if the block is an autoblock and would exceed the user block + # if renewed. If so, do nothing, otherwise prolong the block time... + if ( $ipblock->mAuto && // @TODO: why not compare $ipblock->mExpiry? + $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) ) { - # If the block is an autoblock, reset its timestamp to now and its expiry - # to an $wgAutoblockExpiry in the future; otherwise do nothing + # Reset block timestamp to now and its expiry to + # $wgAutoblockExpiry in the future $ipblock->updateTimestamp(); } return false; - } - # Make a new block object with the desired properties + # Make a new block object with the desired properties. $autoblock = new Block; wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" ); $autoblock->setTarget( $autoblockIP ); @@ -630,7 +630,7 @@ class Block { $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( wfTimestampNow() ) ); } - # Insert it + # Insert the block... $status = $autoblock->insert(); return $status ? $status['id']