r50162 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50161‎ | r50162 | r50163 >
Date:07:58, 4 May 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Backports for the hide user feature:
* r48886/r48892: suppress log entries where the target is the user page
* r49191/r49192: don't suppress the suppress log
* r49222: suppress RC entries
* r49685: pretend that hide-user is a block by making Special:IPBlocklist submit undo it.
* r49730: don't destroy the archive table
* r50070 (core part only): slightly lower edit count limit
* Removed code formatting changes from the above backports.
Modified paths:
  • /branches/REL1_15/phase3 (modified) (history)
  • /branches/REL1_15/phase3/includes (modified) (history)
  • /branches/REL1_15/phase3/includes/api (modified) (history)
  • /branches/REL1_15/phase3/includes/specials (modified) (history)
  • /branches/REL1_15/phase3/includes/specials/SpecialBlockip.php (modified) (history)
  • /branches/REL1_15/phase3/includes/specials/SpecialIpblocklist.php (modified) (history)

Diff [purge]

Property changes on: branches/REL1_15/phase3/includes/api
___________________________________________________________________
Name: svn:mergeinfo
11 - /trunk/phase3/includes/api:48813-48814,48819,48836,48909,48989,48992,49051,49068,49086,49682,49775
22 + /trunk/phase3/includes/api:48813-48814,48819,48836,48886,48892,48909,48989,48992,49051,49068,49086,49191-49192,49682,49685,49730,49775,50070
Index: branches/REL1_15/phase3/includes/specials/SpecialIpblocklist.php
@@ -162,7 +162,7 @@
163163 * @return array array(message key, parameters) on failure, empty array on success
164164 */
165165
166 - static function doUnblock(&$id, &$ip, &$reason, &$range = null) {
 166+ static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker=null) {
167167 if ( $id ) {
168168 $block = Block::newFromID( $id );
169169 if ( !$block ) {
@@ -195,11 +195,22 @@
196196 }
197197 // Yes, this is really necessary
198198 $id = $block->mId;
 199+
 200+ # If the name was hidden and the blocking user cannot hide
 201+ # names, then don't allow any block removals...
 202+ if( $blocker && $block->mHideName && !$blocker->isAllowed('hideuser') ) {
 203+ return array('ipb_cant_unblock', htmlspecialchars($id));
 204+ }
199205
200206 # Delete block
201207 if ( !$block->delete() ) {
202208 return array('ipb_cant_unblock', htmlspecialchars($id));
203209 }
 210+
 211+ # Unset _deleted fields as needed
 212+ if( $block->mHideName ) {
 213+ IPBlockForm::unsuppressUserName( $block->mAddress, $block->mUser );
 214+ }
204215
205216 # Make log entry
206217 $log = new LogPage( 'block' );
@@ -208,8 +219,8 @@
209220 }
210221
211222 function doSubmit() {
212 - global $wgOut;
213 - $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range);
 223+ global $wgOut, $wgUser;
 224+ $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range, $wgUser);
214225 if(!empty($retval))
215226 {
216227 $key = array_shift($retval);
Index: branches/REL1_15/phase3/includes/specials/SpecialBlockip.php
@@ -45,6 +45,8 @@
4646 class IPBlockForm {
4747 var $BlockAddress, $BlockExpiry, $BlockReason;
4848 # var $BlockEmail;
 49+ // The maximum number of edits a user can have and still be hidden
 50+ const HIDEUSER_CONTRIBLIMIT = 1000;
4951
5052 function IPBlockForm( $par ) {
5153 global $wgRequest, $wgUser, $wgBlockAllowsUTEdit;
@@ -401,7 +403,7 @@
402404 } else if( $expiry !== 'infinity' ) {
403405 // Bad expiry.
404406 return array('ipb_expiry_temp');
405 - } else if( User::edits($userId) > 3000 ) {
 407+ } else if( User::edits($userId) > self::HIDEUSER_CONTRIBLIMIT ) {
406408 // Typically, the user should have a handful of edits.
407409 // Disallow hiding users with many edits for performance.
408410 return array('ipb_hide_invalid');
@@ -444,7 +446,7 @@
445447 $log_action = 'reblock';
446448 # Unset _deleted fields if requested
447449 if( $currentBlock->mHideName && !$this->BlockHideName ) {
448 - $this->unsuppressUserName( $this->BlockAddress, $userId );
 450+ self::unsuppressUserName( $this->BlockAddress, $userId );
449451 }
450452 }
451453 } else {
@@ -454,7 +456,7 @@
455457
456458 # Set *_deleted fields if requested
457459 if( $this->BlockHideName ) {
458 - $this->suppressUserName( $this->BlockAddress, $userId );
 460+ self::suppressUserName( $this->BlockAddress, $userId );
459461 }
460462
461463 if ( $this->BlockWatchUser &&
@@ -485,36 +487,46 @@
486488 }
487489 }
488490
489 - private function suppressUserName( $name, $userId ) {
 491+ public static function suppressUserName( $name, $userId ) {
490492 $op = '|'; // bitwise OR
491 - return $this->setUsernameBitfields( $name, $userId, $op );
 493+ return self::setUsernameBitfields( $name, $userId, $op );
492494 }
493495
494 - private function unsuppressUserName( $name, $userId ) {
 496+ public static function unsuppressUserName( $name, $userId ) {
495497 $op = '&'; // bitwise AND
496 - return $this->setUsernameBitfields( $name, $userId, $op );
 498+ return self::setUsernameBitfields( $name, $userId, $op );
497499 }
498500
499 - private function setUsernameBitfields( $name, $userId, $op ) {
 501+ private static function setUsernameBitfields( $name, $userId, $op ) {
500502 if( $op !== '|' && $op !== '&' )
501503 return false; // sanity check
502504 $dbw = wfGetDB( DB_MASTER );
503505 $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
 506+ $delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED;
 507+ # Normalize user name
 508+ $userTitle = Title::makeTitleSafe( NS_USER, $name );
 509+ $userDbKey = $userTitle->getDBKey();
504510 # To suppress, we OR the current bitfields with Revision::DELETED_USER
505511 # to put a 1 in the username *_deleted bit. To unsuppress we AND the
506512 # current bitfields with the inverse of Revision::DELETED_USER. The
507513 # username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x).
508514 # The same goes for the sysop-restricted *_deleted bit.
509 - if( $op == '&' ) $delUser = "~{$delUser}";
 515+ if( $op == '&' ) {
 516+ $delUser = "~{$delUser}";
 517+ $delAction = "~{$delAction}";
 518+ }
510519 # Hide name from live edits
511520 $dbw->update( 'revision', array("rev_deleted = rev_deleted $op $delUser"),
512521 array('rev_user' => $userId), __METHOD__ );
513522 # Hide name from deleted edits
514523 $dbw->update( 'archive', array("ar_deleted = ar_deleted $op $delUser"),
515 - array('ar_user_text' => $userId), __METHOD__ );
 524+ array('ar_user_text' => $name), __METHOD__ );
516525 # Hide name from logs
517526 $dbw->update( 'logging', array("log_deleted = log_deleted $op $delUser"),
518 - array('log_user' => $userId), __METHOD__ );
 527+ array('log_user' => $userId, "log_type != 'suppress'"), __METHOD__ );
 528+ $dbw->update( 'logging', array("log_deleted = log_deleted $op $delAction"),
 529+ array('log_namespace' => NS_USER, 'log_title' => $userDbKey,
 530+ "log_type != 'suppress'"), __METHOD__ );
519531 # Hide name from RC
520532 $dbw->update( 'recentchanges', array("rc_deleted = rc_deleted $op $delUser"),
521533 array('rc_user_text' => $name), __METHOD__ );
Property changes on: branches/REL1_15/phase3/includes/specials
___________________________________________________________________
Name: svn:mergeinfo
522534 - /trunk/phase3/includes/specials:48836,48989,48992-48993,49051,49068,49086,49682,49775
/trunk/phase3/includes/specials/specials:48993
523535 + /trunk/phase3/includes/specials:48836,48886,48892,48989,48992-48993,49051,49068,49086,49191-49192,49682,49685,49730,49775,50070
/trunk/phase3/includes/specials/specials:48993
Property changes on: branches/REL1_15/phase3/includes
___________________________________________________________________
Name: svn:mergeinfo
524536 - /trunk/phase3/includes:48836,48989,48992,49051,49068,49086,49682,49775
/trunk/phase3/includes/specials:48993
525537 + /trunk/phase3/includes:48836,48886,48892,48989,48992,49051,49068,49086,49191-49192,49682,49685,49730,49775,50070
/trunk/phase3/includes/specials:48993
Property changes on: branches/REL1_15/phase3
___________________________________________________________________
Name: svn:mergeinfo
526538 - /trunk/phase3:48814,48836,48909,48989,48992,49051,49068,49086,49682,49775
527539 + /trunk/phase3:48814,48836,48886,48892,48909,48989,48992,49051,49068,49086,49191-49192,49682,49685,49730,49775,50070

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r48886Hide log items with said user as the target as wellaaron16:46, 26 March 2009
r48892Fix r48886: make sure title is normalized for queryaaron18:53, 26 March 2009
r49191setUsernameBitfields() should skip suppress log itemsaaron01:32, 5 April 2009
r49192Follow-up to r49191: Same thing but where the log is by an Oversighter.aaron02:02, 5 April 2009
r49222(bug 18346) Automatically hide RC log items on block tooaaron19:17, 5 April 2009
r49685* Fixed unblocking of hidden names (bug 18543)...aaron04:43, 21 April 2009
r49730fix silly typoaaron05:56, 22 April 2009
r50070Tweaked account hiding & renaming limitsaaron07:19, 30 April 2009

Status & tagging log