Index: trunk/phase3/includes/Block.php |
— | — | @@ -562,10 +562,9 @@ |
563 | 563 | * Autoblocks the given IP, referring to this Block. |
564 | 564 | * |
565 | 565 | * @param $autoblockIP String: the IP to autoblock. |
566 | | - * @param $justInserted Boolean: the main block was just inserted. |
567 | 566 | * @return mixed: block ID if an autoblock was inserted, false if not. |
568 | 567 | */ |
569 | | - public function doAutoblock( $autoblockIP, $justInserted = false ) { |
| 568 | + public function doAutoblock( $autoblockIP ) { |
570 | 569 | # If autoblocks are disabled, go away. |
571 | 570 | if ( !$this->isAutoblocking() ) { |
572 | 571 | return false; |
— | — | @@ -589,45 +588,44 @@ |
590 | 589 | # If the user is already blocked. Then check if the autoblock would |
591 | 590 | # exceed the user block. If it would exceed, then do nothing, else |
592 | 591 | # prolong block time |
593 | | - if ( $this->mExpiry && |
594 | | - ( $this->mExpiry < Block::getAutoblockExpiry( $ipblock->mTimestamp ) ) |
| 592 | + if ( $this->mExpiry > Block::getAutoblockExpiry( $ipblock->mTimestamp ) |
595 | 593 | ) { |
596 | | - return false; |
597 | | - } |
598 | | - |
599 | | - # Just update the timestamp |
600 | | - if ( !$justInserted ) { |
| 594 | + # If the block is an autoblock, reset its timestamp to now and its expiry |
| 595 | + # to an $wgAutoblockExpiry in the future; otherwise do nothing |
601 | 596 | $ipblock->updateTimestamp(); |
602 | 597 | } |
603 | | - |
604 | 598 | return false; |
605 | | - } else { |
606 | | - $ipblock = new Block; |
| 599 | + |
607 | 600 | } |
608 | 601 | |
609 | 602 | # Make a new block object with the desired properties |
| 603 | + $autoblock = new Block; |
610 | 604 | wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" ); |
611 | | - $ipblock->setTarget( $autoblockIP ); |
612 | | - $ipblock->setBlocker( $this->getBlocker() ); |
613 | | - $ipblock->mReason = wfMsgForContent( 'autoblocker', $this->getTarget(), $this->mReason ); |
614 | | - $ipblock->mTimestamp = wfTimestampNow(); |
615 | | - $ipblock->mAuto = 1; |
616 | | - $ipblock->mCreateAccount = $this->mCreateAccount; |
| 605 | + $autoblock->setTarget( $autoblockIP ); |
| 606 | + $autoblock->setBlocker( $this->getBlocker() ); |
| 607 | + $autoblock->mReason = wfMsgForContent( 'autoblocker', $this->getTarget(), $this->mReason ); |
| 608 | + $autoblock->mTimestamp = wfTimestampNow(); |
| 609 | + $autoblock->mAuto = 1; |
| 610 | + $autoblock->prevents( 'createaccount', $this->prevents( 'createaccount' ) ); |
617 | 611 | # Continue suppressing the name if needed |
618 | | - $ipblock->mHideName = $this->mHideName; |
619 | | - $ipblock->mDisableUsertalk = $this->mDisableUsertalk; |
| 612 | + $autoblock->mHideName = $this->mHideName; |
| 613 | + $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) ); |
620 | 614 | |
621 | | - # If the user is already blocked with an expiry date, we don't |
622 | | - # want to pile on top of that! |
623 | | - if ( $this->mExpiry ) { |
624 | | - $ipblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $this->mTimestamp ) ); |
| 615 | + $dbr = wfGetDB( DB_READ ); |
| 616 | + if ( $this->mTimestamp == $dbr->getInfinity() ) { |
| 617 | + # Original block was indefinite, start an autoblock now |
| 618 | + $autoblock->mExpiry = Block::getAutoblockExpiry( wfTimestampNow() ); |
625 | 619 | } else { |
626 | | - $ipblock->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp ); |
| 620 | + # If the user is already blocked with an expiry date, we don't |
| 621 | + # want to pile on top of that. |
| 622 | + $autoblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( wfTimestampNow() ) ); |
627 | 623 | } |
628 | 624 | |
629 | 625 | # Insert it |
630 | | - $status = $ipblock->insert(); |
631 | | - return $status ? $status['id'] : false; |
| 626 | + $status = $autoblock->insert(); |
| 627 | + return $status |
| 628 | + ? $status['id'] |
| 629 | + : false; |
632 | 630 | } |
633 | 631 | |
634 | 632 | /** |