From 3535e4e84e3e1c30f68b47e18f9329c3e59dcafe Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Wed, 2 Jan 2019 10:30:34 +0100 Subject: [PATCH] Update type hints and documentation of RevisionDeleteUser Technically unrelated, but motivated by Ib59cf77. Change-Id: I54cb9c396552d6982f5ca8463e00a0769e60a291 --- .../revisiondelete/RevisionDeleteUser.php | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/includes/revisiondelete/RevisionDeleteUser.php b/includes/revisiondelete/RevisionDeleteUser.php index 34b624fce2..f7f7e8956a 100644 --- a/includes/revisiondelete/RevisionDeleteUser.php +++ b/includes/revisiondelete/RevisionDeleteUser.php @@ -35,13 +35,14 @@ class RevisionDeleteUser { /** * Update *_deleted bitfields in various tables to hide or unhide usernames + * * @param string $name Username * @param int $userId User id * @param string $op Operator '|' or '&' * @param null|IDatabase $dbw If you happen to have one lying around - * @return bool + * @return bool True on success, false on failure (e.g. invalid user ID) */ - private static function setUsernameBitfields( $name, $userId, $op, $dbw ) { + private static function setUsernameBitfields( $name, $userId, $op, IDatabase $dbw = null ) { global $wgActorTableSchemaMigrationStage; if ( !$userId || ( $op !== '|' && $op !== '&' ) ) { @@ -58,7 +59,7 @@ class RevisionDeleteUser { # The same goes for the sysop-restricted *_deleted bit. $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; $delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED; - if ( $op == '&' ) { + if ( $op === '&' ) { $delUser = $dbw->bitNot( $delUser ); $delAction = $dbw->bitNot( $delAction ); } @@ -194,17 +195,29 @@ class RevisionDeleteUser { return true; } - private static function buildSetBitDeletedField( $field, $op, $value, $dbw ) { + private static function buildSetBitDeletedField( $field, $op, $value, IDatabase $dbw ) { return $field . ' = ' . ( $op === '&' ? $dbw->bitAnd( $field, $value ) : $dbw->bitOr( $field, $value ) ); } - public static function suppressUserName( $name, $userId, $dbw = null ) { + /** + * @param string $name User name + * @param int $userId Both user name and ID must be provided + * @param IDatabase|null $dbw If you happen to have one lying around + * @return bool True on success, false on failure (e.g. invalid user ID) + */ + public static function suppressUserName( $name, $userId, IDatabase $dbw = null ) { return self::setUsernameBitfields( $name, $userId, '|', $dbw ); } - public static function unsuppressUserName( $name, $userId, $dbw = null ) { + /** + * @param string $name User name + * @param int $userId Both user name and ID must be provided + * @param IDatabase|null $dbw If you happen to have one lying around + * @return bool True on success, false on failure (e.g. invalid user ID) + */ + public static function unsuppressUserName( $name, $userId, IDatabase $dbw = null ) { return self::setUsernameBitfields( $name, $userId, '&', $dbw ); } } -- 2.20.1