diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /includes/revisiondelete/RevisionDeleteUser.php | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/revisiondelete/RevisionDeleteUser.php')
-rw-r--r-- | includes/revisiondelete/RevisionDeleteUser.php | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php index 4505ee10..55c46c5e 100644 --- a/includes/revisiondelete/RevisionDeleteUser.php +++ b/includes/revisiondelete/RevisionDeleteUser.php @@ -33,10 +33,10 @@ class RevisionDeleteUser { /** * Update *_deleted bitfields in various tables to hide or unhide usernames - * @param $name String username - * @param $userId Int user id - * @param $op String operator '|' or '&' - * @param $dbw null|DatabaseBase, if you happen to have one lying around + * @param string $name Username + * @param int $userId User id + * @param string $op Operator '|' or '&' + * @param null|DatabaseBase $dbw If you happen to have one lying around * @return bool */ private static function setUsernameBitfields( $name, $userId, $op, $dbw ) { @@ -55,8 +55,8 @@ class RevisionDeleteUser { $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; $delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED; if ( $op == '&' ) { - $delUser = "~{$delUser}"; - $delAction = "~{$delAction}"; + $delUser = $dbw->bitNot( $delUser ); + $delAction = $dbw->bitNot( $delAction ); } # Normalize user name @@ -66,14 +66,14 @@ class RevisionDeleteUser { # Hide name from live edits $dbw->update( 'revision', - array( "rev_deleted = rev_deleted $op $delUser" ), + array( self::buildSetBitDeletedField( 'rev_deleted', $op, $delUser, $dbw ) ), array( 'rev_user' => $userId ), __METHOD__ ); # Hide name from deleted edits $dbw->update( 'archive', - array( "ar_deleted = ar_deleted $op $delUser" ), + array( self::buildSetBitDeletedField( 'ar_deleted', $op, $delUser, $dbw ) ), array( 'ar_user_text' => $name ), __METHOD__ ); @@ -81,28 +81,28 @@ class RevisionDeleteUser { # Hide name from logs $dbw->update( 'logging', - array( "log_deleted = log_deleted $op $delUser" ), - array( 'log_user' => $userId, "log_type != 'suppress'" ), + array( self::buildSetBitDeletedField( 'log_deleted', $op, $delUser, $dbw ) ), + array( 'log_user' => $userId, 'log_type != ' . $dbw->addQuotes( 'suppress' ) ), __METHOD__ ); $dbw->update( 'logging', - array( "log_deleted = log_deleted $op $delAction" ), + array( self::buildSetBitDeletedField( 'log_deleted', $op, $delAction, $dbw ) ), array( 'log_namespace' => NS_USER, 'log_title' => $userDbKey, - "log_type != 'suppress'" ), + 'log_type != ' . $dbw->addQuotes( 'suppress' ) ), __METHOD__ ); # Hide name from RC $dbw->update( 'recentchanges', - array( "rc_deleted = rc_deleted $op $delUser" ), + array( self::buildSetBitDeletedField( 'rc_deleted', $op, $delUser, $dbw ) ), array( 'rc_user_text' => $name ), __METHOD__ ); $dbw->update( 'recentchanges', - array( "rc_deleted = rc_deleted $op $delAction" ), + array( self::buildSetBitDeletedField( 'rc_deleted', $op, $delAction, $dbw ) ), array( 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ), __METHOD__ ); @@ -110,7 +110,7 @@ class RevisionDeleteUser { # Hide name from live images $dbw->update( 'oldimage', - array( "oi_deleted = oi_deleted $op $delUser" ), + array( self::buildSetBitDeletedField( 'oi_deleted', $op, $delUser, $dbw ) ), array( 'oi_user_text' => $name ), __METHOD__ ); @@ -118,7 +118,7 @@ class RevisionDeleteUser { # Hide name from deleted images $dbw->update( 'filearchive', - array( "fa_deleted = fa_deleted $op $delUser" ), + array( self::buildSetBitDeletedField( 'fa_deleted', $op, $delUser, $dbw ) ), array( 'fa_user_text' => $name ), __METHOD__ ); @@ -126,6 +126,12 @@ class RevisionDeleteUser { return true; } + private static function buildSetBitDeletedField( $field, $op, $value, $dbw ) { + return $field . ' = ' . ( $op === '&' + ? $dbw->bitAnd( $field, $value ) + : $dbw->bitOr( $field, $value ) ); + } + public static function suppressUserName( $name, $userId, $dbw = null ) { return self::setUsernameBitfields( $name, $userId, '|', $dbw ); } |