* Only spread blocks on page edit/move attempts via spreadAnyEditBlock(). We don...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 8 Oct 2011 20:22:53 +0000 (20:22 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 8 Oct 2011 20:22:53 +0000 (20:22 +0000)
* Made spreadBlock() protected, no outside callers.

includes/EditPage.php
includes/User.php
includes/specials/SpecialMovepage.php

index 6714e0f..e5b0fbf 100644 (file)
@@ -405,6 +405,9 @@ class EditPage {
 
                $permErrors = $this->getEditPermissionErrors();
                if ( $permErrors ) {
+                       // Auto-block user's IP if the account was "hard" blocked
+                       $wgUser->spreadAnyEditBlock();
+
                        wfDebug( __METHOD__ . ": User can't edit\n" );
                        $content = $this->getContent( null );
                        $content = $content === '' ? null : $content;
index 455c990..3710694 100644 (file)
@@ -1284,9 +1284,6 @@ class User {
                        $this->mBlockreason = $this->mBlock->mReason;
                        $this->mHideName = $this->mBlock->mHideName;
                        $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
-                       if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
-                               $this->spreadBlock();
-                       }
                }
 
                # Proxy blocking
@@ -2940,22 +2937,35 @@ class User {
        }
 
        /**
-        * If this (non-anonymous) user is blocked, block any IP address
-        * they've successfully logged in from.
+        * If this user is logged-in and blocked,
+        * block any IP address they've successfully logged in from.
+        * @return bool A block was spread
         */
-       public function spreadBlock() {
+       public function spreadAnyEditBlock() {
+               if ( $this->isLoggedIn() && $this->isBlocked() ) {
+                       return $this->spreadBlock();
+               }
+               return false;
+       }
+
+       /**
+        * If this (non-anonymous) user is blocked,
+        * block the IP address they've successfully logged in from.
+        * @return bool A block was spread
+        */
+       protected function spreadBlock() {
                wfDebug( __METHOD__ . "()\n" );
                $this->load();
                if ( $this->mId == 0 ) {
-                       return;
+                       return false;
                }
 
                $userblock = Block::newFromTarget( $this->getName() );
                if ( !$userblock ) {
-                       return;
+                       return false;
                }
 
-               $userblock->doAutoblock( $this->getRequest()->getIP() );
+               return (bool)$userblock->doAutoblock( $this->getRequest()->getIP() );
        }
 
        /**
index f4cc150..8b52fd8 100644 (file)
@@ -72,6 +72,8 @@ class MovePageForm extends UnlistedSpecialPage {
                # Check rights
                $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
                if( !empty( $permErrors ) ) {
+                       // Auto-block user's IP if the account was "hard" blocked
+                       $user->spreadAnyEditBlock();
                        $this->getOutput()->showPermissionsErrorPage( $permErrors );
                        return;
                }