46 private static function setUsernameBitfields( $name, $userId, $op,
IDatabase $dbw =
null ) {
47 if ( !$userId || ( $op !==
'|' && $op !==
'&' ) ) {
54 # To suppress, we OR the current bitfields with RevisionRecord::DELETED_USER
55 # to put a 1 in the username *_deleted bit. To unsuppress we AND the
56 # current bitfields with the inverse of RevisionRecord::DELETED_USER. The
57 # username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x).
58 # The same goes for the sysop-restricted *_deleted bit.
59 $delUser = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
62 $delUser = $dbw->bitNot( $delUser );
63 $delAction = $dbw->bitNot( $delAction );
67 $userTitle = Title::makeTitleSafe(
NS_USER, $name );
68 $userDbKey = $userTitle->getDBkey();
70 $actorId = $dbw->selectField(
'actor',
'actor_id', [
'actor_name' => $name ], __METHOD__ );
72 # Hide name from live edits
75 [ self::buildSetBitDeletedField(
'rev_deleted', $op, $delUser, $dbw ) ],
76 [
'rev_actor' => $actorId ],
80 # Hide name from deleted edits
83 [ self::buildSetBitDeletedField(
'ar_deleted', $op, $delUser, $dbw ) ],
84 [
'ar_actor' => $actorId ],
91 [ self::buildSetBitDeletedField(
'log_deleted', $op, $delUser, $dbw ) ],
92 [
'log_actor' => $actorId,
'log_type != ' . $dbw->addQuotes(
'suppress' ) ],
99 [ self::buildSetBitDeletedField(
'rc_deleted', $op, $delUser, $dbw ) ],
100 [
'rc_actor' => $actorId ],
104 # Hide name from live images
107 [ self::buildSetBitDeletedField(
'oi_deleted', $op, $delUser, $dbw ) ],
108 [
'oi_actor' => $actorId ],
112 # Hide name from deleted images
115 [ self::buildSetBitDeletedField(
'fa_deleted', $op, $delUser, $dbw ) ],
116 [
'fa_actor' => $actorId ],
121 # Hide log entries pointing to the user page
124 [ self::buildSetBitDeletedField(
'log_deleted', $op, $delAction, $dbw ) ],
125 [
'log_namespace' =>
NS_USER,
'log_title' => $userDbKey,
126 'log_type != ' . $dbw->addQuotes(
'suppress' ) ],
130 # Hide RC entries pointing to the user page
133 [ self::buildSetBitDeletedField(
'rc_deleted', $op, $delAction, $dbw ) ],
134 [
'rc_namespace' =>
NS_USER,
'rc_title' => $userDbKey,
'rc_logid > 0' ],
141 private static function buildSetBitDeletedField( $field, $op, $value,
IDatabase $dbw ) {
142 return $field .
' = ' . ( $op ===
'&'
143 ? $dbw->
bitAnd( $field, $value )
144 : $dbw->
bitOr( $field, $value ) );
154 return self::setUsernameBitfields( $name, $userId,
'|', $dbw );
164 return self::setUsernameBitfields( $name, $userId,
'&', $dbw );