r100655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100654‎ | r100655 | r100656 >
Date:22:27, 24 October 2011
Author:aaron
Status:ok
Tags:
Comment:
MFT r99323, r99349 - 'Only spread blocks on page edit/move attempts via spreadAnyEditBlock()...'
Modified paths:
  • /branches/wmf/1.18wmf1/includes/EditPage.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/Title.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/User.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/User.php
@@ -1274,9 +1274,6 @@
12751275 $this->mBlockreason = $this->mBlock->mReason;
12761276 $this->mHideName = $this->mBlock->mHideName;
12771277 $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
1278 - if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
1279 - $this->spreadBlock();
1280 - }
12811278 }
12821279
12831280 # Proxy blocking
@@ -2906,22 +2903,35 @@
29072904 }
29082905
29092906 /**
2910 - * If this (non-anonymous) user is blocked, block any IP address
2911 - * they've successfully logged in from.
 2907+ * If this user is logged-in and blocked,
 2908+ * block any IP address they've successfully logged in from.
 2909+ * @return bool A block was spread
29122910 */
2913 - public function spreadBlock() {
 2911+ public function spreadAnyEditBlock() {
 2912+ if ( $this->isLoggedIn() && $this->isBlocked() ) {
 2913+ return $this->spreadBlock();
 2914+ }
 2915+ return false;
 2916+ }
 2917+
 2918+ /**
 2919+ * If this (non-anonymous) user is blocked,
 2920+ * block the IP address they've successfully logged in from.
 2921+ * @return bool A block was spread
 2922+ */
 2923+ protected function spreadBlock() {
29142924 wfDebug( __METHOD__ . "()\n" );
29152925 $this->load();
29162926 if ( $this->mId == 0 ) {
2917 - return;
 2927+ return false;
29182928 }
29192929
29202930 $userblock = Block::newFromTarget( $this->getName() );
29212931 if ( !$userblock ) {
2922 - return;
 2932+ return false;
29232933 }
29242934
2925 - $userblock->doAutoblock( wfGetIP() );
 2935+ return (bool)$userblock->doAutoblock( $this->getRequest()->getIP() );
29262936 }
29272937
29282938 /**
Index: branches/wmf/1.18wmf1/includes/EditPage.php
@@ -402,6 +402,9 @@
403403
404404 $permErrors = $this->getEditPermissionErrors();
405405 if ( $permErrors ) {
 406+ // Auto-block user's IP if the account was "hard" blocked
 407+ $wgUser->spreadAnyEditBlock();
 408+
406409 wfDebug( __METHOD__ . ": User can't edit\n" );
407410 $content = $this->getContent( null );
408411 $content = $content === '' ? null : $content;
@@ -934,6 +937,8 @@
935938 return $status;
936939 }
937940 if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
 941+ // Auto-block user's IP if the account was "hard" blocked
 942+ $wgUser->spreadAnyEditBlock();
938943 # Check block state against master, thus 'false'.
939944 $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
940945 wfProfileOut( __METHOD__ . '-checks' );
Index: branches/wmf/1.18wmf1/includes/Title.php
@@ -3139,8 +3139,11 @@
31403140 * @return Mixed true on success, getUserPermissionsErrors()-like array on failure
31413141 */
31423142 public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) {
 3143+ global $wgUser;
31433144 $err = $this->isValidMoveOperation( $nt, $auth, $reason );
31443145 if ( is_array( $err ) ) {
 3146+ // Auto-block user's IP if the account was "hard" blocked
 3147+ $wgUser->spreadAnyEditBlock();
31453148 return $err;
31463149 }
31473150
Index: branches/wmf/1.18wmf1/includes/specials/SpecialMovepage.php
@@ -74,7 +74,9 @@
7575 # Check rights
7676 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $wgUser );
7777 if( !empty( $permErrors ) ) {
78 - $wgOut->showPermissionsErrorPage( $permErrors );
 78+ // Auto-block user's IP if the account was "hard" blocked
 79+ $user->spreadAnyEditBlock();
 80+ $this->getOutput()->showPermissionsErrorPage( $permErrors );
7981 return;
8082 }
8183

Follow-up revisions

RevisionCommit summaryAuthorDate
r100657Fixed merge mismatches in r100655aaron22:33, 24 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99323* Only spread blocks on page edit/move attempts via spreadAnyEditBlock(). We ...aaron20:22, 8 October 2011
r99349FU r99323: spread blocks for edit/move attempts via the API (which uses these...aaron12:30, 9 October 2011

Status & tagging log