Index: trunk/phase3/includes/Block.php |
— | — | @@ -579,35 +579,35 @@ |
580 | 580 | return false; |
581 | 581 | } |
582 | 582 | |
583 | | - # Check for presence on the autoblock whitelist |
| 583 | + # Check for presence on the autoblock whitelist. |
584 | 584 | if ( self::isWhitelistedFromAutoblocks( $autoblockIP ) ) { |
585 | 585 | return false; |
586 | 586 | } |
587 | 587 | |
588 | | - # # Allow hooks to cancel the autoblock. |
| 588 | + # Allow hooks to cancel the autoblock. |
589 | 589 | if ( !wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) { |
590 | 590 | wfDebug( "Autoblock aborted by hook.\n" ); |
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | |
594 | | - # It's okay to autoblock. Go ahead and create/insert the block. |
| 594 | + # It's okay to autoblock. Go ahead and insert/update the block... |
595 | 595 | |
| 596 | + # Do not add a *new* block if the IP is already blocked. |
596 | 597 | $ipblock = Block::newFromTarget( $autoblockIP ); |
597 | 598 | if ( $ipblock ) { |
598 | | - # If the user is already blocked. Then check if the autoblock would |
599 | | - # exceed the user block. If it would exceed, then do nothing, else |
600 | | - # prolong block time |
601 | | - if ( $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) |
| 599 | + # Check if the block is an autoblock and would exceed the user block |
| 600 | + # if renewed. If so, do nothing, otherwise prolong the block time... |
| 601 | + if ( $ipblock->mAuto && // @TODO: why not compare $ipblock->mExpiry? |
| 602 | + $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) |
602 | 603 | ) { |
603 | | - # If the block is an autoblock, reset its timestamp to now and its expiry |
604 | | - # to an $wgAutoblockExpiry in the future; otherwise do nothing |
| 604 | + # Reset block timestamp to now and its expiry to |
| 605 | + # $wgAutoblockExpiry in the future |
605 | 606 | $ipblock->updateTimestamp(); |
606 | 607 | } |
607 | 608 | return false; |
608 | | - |
609 | 609 | } |
610 | 610 | |
611 | | - # Make a new block object with the desired properties |
| 611 | + # Make a new block object with the desired properties. |
612 | 612 | $autoblock = new Block; |
613 | 613 | wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" ); |
614 | 614 | $autoblock->setTarget( $autoblockIP ); |
— | — | @@ -630,7 +630,7 @@ |
631 | 631 | $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( wfTimestampNow() ) ); |
632 | 632 | } |
633 | 633 | |
634 | | - # Insert it |
| 634 | + # Insert the block... |
635 | 635 | $status = $autoblock->insert(); |
636 | 636 | return $status |
637 | 637 | ? $status['id'] |