http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99323
Revision: 99323 Author: aaron Date: 2011-10-08 20:22:53 +0000 (Sat, 08 Oct 2011) Log Message: ----------- * Only spread blocks on page edit/move attempts via spreadAnyEditBlock(). We don't want to spread everytime the user's block status is checked as the user may just be viewing something rather than attempting to do anything. For example, if the 'edit' tab were changed to reflect block status, the autoblocks would trigger by a user just *looking* at the page. An example "in the wild" would be the UI checks in r93246. * Made spreadBlock() protected, no outside callers. Modified Paths: -------------- trunk/phase3/includes/EditPage.php trunk/phase3/includes/User.php trunk/phase3/includes/specials/SpecialMovepage.php Modified: trunk/phase3/includes/EditPage.php =================================================================== --- trunk/phase3/includes/EditPage.php 2011-10-08 19:41:35 UTC (rev 99322) +++ trunk/phase3/includes/EditPage.php 2011-10-08 20:22:53 UTC (rev 99323) @@ -405,6 +405,9 @@ $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; Modified: trunk/phase3/includes/User.php =================================================================== --- trunk/phase3/includes/User.php 2011-10-08 19:41:35 UTC (rev 99322) +++ trunk/phase3/includes/User.php 2011-10-08 20:22:53 UTC (rev 99323) @@ -1284,9 +1284,6 @@ $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 @@ } /** - * 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() ); } /** Modified: trunk/phase3/includes/specials/SpecialMovepage.php =================================================================== --- trunk/phase3/includes/specials/SpecialMovepage.php 2011-10-08 19:41:35 UTC (rev 99322) +++ trunk/phase3/includes/specials/SpecialMovepage.php 2011-10-08 20:22:53 UTC (rev 99323) @@ -72,6 +72,8 @@ # 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; } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs