r99323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99322‎ | r99323 | r99324 >
Date:20:22, 8 October 2011
Author:aaron
Status:ok
Tags:
Comment:
* 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 (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1284,9 +1284,6 @@
12851285 $this->mBlockreason = $this->mBlock->mReason;
12861286 $this->mHideName = $this->mBlock->mHideName;
12871287 $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
1288 - if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
1289 - $this->spreadBlock();
1290 - }
12911288 }
12921289
12931290 # Proxy blocking
@@ -2940,22 +2937,35 @@
29412938 }
29422939
29432940 /**
2944 - * If this (non-anonymous) user is blocked, block any IP address
2945 - * they've successfully logged in from.
 2941+ * If this user is logged-in and blocked,
 2942+ * block any IP address they've successfully logged in from.
 2943+ * @return bool A block was spread
29462944 */
2947 - public function spreadBlock() {
 2945+ public function spreadAnyEditBlock() {
 2946+ if ( $this->isLoggedIn() && $this->isBlocked() ) {
 2947+ return $this->spreadBlock();
 2948+ }
 2949+ return false;
 2950+ }
 2951+
 2952+ /**
 2953+ * If this (non-anonymous) user is blocked,
 2954+ * block the IP address they've successfully logged in from.
 2955+ * @return bool A block was spread
 2956+ */
 2957+ protected function spreadBlock() {
29482958 wfDebug( __METHOD__ . "()\n" );
29492959 $this->load();
29502960 if ( $this->mId == 0 ) {
2951 - return;
 2961+ return false;
29522962 }
29532963
29542964 $userblock = Block::newFromTarget( $this->getName() );
29552965 if ( !$userblock ) {
2956 - return;
 2966+ return false;
29572967 }
29582968
2959 - $userblock->doAutoblock( $this->getRequest()->getIP() );
 2969+ return (bool)$userblock->doAutoblock( $this->getRequest()->getIP() );
29602970 }
29612971
29622972 /**
Index: trunk/phase3/includes/EditPage.php
@@ -405,6 +405,9 @@
406406
407407 $permErrors = $this->getEditPermissionErrors();
408408 if ( $permErrors ) {
 409+ // Auto-block user's IP if the account was "hard" blocked
 410+ $wgUser->spreadAnyEditBlock();
 411+
409412 wfDebug( __METHOD__ . ": User can't edit\n" );
410413 $content = $this->getContent( null );
411414 $content = $content === '' ? null : $content;
Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -72,6 +72,8 @@
7373 # Check rights
7474 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
7575 if( !empty( $permErrors ) ) {
 76+ // Auto-block user's IP if the account was "hard" blocked
 77+ $user->spreadAnyEditBlock();
7678 $this->getOutput()->showPermissionsErrorPage( $permErrors );
7779 return;
7880 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r99349FU r99323: spread blocks for edit/move attempts via the API (which uses these...aaron12:30, 9 October 2011
r100492MFT r99323, r99349m r99630reedy02:40, 22 October 2011
r100655MFT r99323, r99349 - 'Only spread blocks on page edit/move attempts via sprea...aaron22:27, 24 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93246(bug 15641) prevent blocked administrators from accessing deleted revisions.happy-melon20:54, 26 July 2011

Status & tagging log