http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100655
Revision: 100655 Author: aaron Date: 2011-10-24 22:27:38 +0000 (Mon, 24 Oct 2011) Log Message: ----------- MFT r99323, r99349 - 'Only spread blocks on page edit/move attempts via spreadAnyEditBlock()...' Modified Paths: -------------- branches/wmf/1.18wmf1/includes/EditPage.php branches/wmf/1.18wmf1/includes/Title.php branches/wmf/1.18wmf1/includes/User.php branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php Modified: branches/wmf/1.18wmf1/includes/EditPage.php =================================================================== --- branches/wmf/1.18wmf1/includes/EditPage.php 2011-10-24 22:21:08 UTC (rev 100654) +++ branches/wmf/1.18wmf1/includes/EditPage.php 2011-10-24 22:27:38 UTC (rev 100655) @@ -402,6 +402,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; @@ -934,6 +937,8 @@ return $status; } if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) { + // Auto-block user's IP if the account was "hard" blocked + $wgUser->spreadAnyEditBlock(); # Check block state against master, thus 'false'. $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER ); wfProfileOut( __METHOD__ . '-checks' ); Modified: branches/wmf/1.18wmf1/includes/Title.php =================================================================== --- branches/wmf/1.18wmf1/includes/Title.php 2011-10-24 22:21:08 UTC (rev 100654) +++ branches/wmf/1.18wmf1/includes/Title.php 2011-10-24 22:27:38 UTC (rev 100655) @@ -3139,8 +3139,11 @@ * @return Mixed true on success, getUserPermissionsErrors()-like array on failure */ public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { + global $wgUser; $err = $this->isValidMoveOperation( $nt, $auth, $reason ); if ( is_array( $err ) ) { + // Auto-block user's IP if the account was "hard" blocked + $wgUser->spreadAnyEditBlock(); return $err; } Modified: branches/wmf/1.18wmf1/includes/User.php =================================================================== --- branches/wmf/1.18wmf1/includes/User.php 2011-10-24 22:21:08 UTC (rev 100654) +++ branches/wmf/1.18wmf1/includes/User.php 2011-10-24 22:27:38 UTC (rev 100655) @@ -1274,9 +1274,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 @@ -2906,22 +2903,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( wfGetIP() ); + return (bool)$userblock->doAutoblock( $this->getRequest()->getIP() ); } /** Modified: branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php =================================================================== --- branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php 2011-10-24 22:21:08 UTC (rev 100654) +++ branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php 2011-10-24 22:27:38 UTC (rev 100655) @@ -74,7 +74,9 @@ # Check rights $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $wgUser ); if( !empty( $permErrors ) ) { - $wgOut->showPermissionsErrorPage( $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