diff options
Diffstat (limited to 'includes/cache/UserCache.php')
-rw-r--r-- | includes/cache/UserCache.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php index 6ec23669..6085f586 100644 --- a/includes/cache/UserCache.php +++ b/includes/cache/UserCache.php @@ -45,7 +45,7 @@ class UserCache { * Get a property of a user based on their user ID * * @param $userId integer User ID - * @param $prop string User property + * @param string $prop User property * @return mixed The property or false if the user does not exist */ public function getProp( $userId, $prop ) { @@ -59,10 +59,21 @@ class UserCache { } /** + * Get the name of a user or return $ip if the user ID is 0 + * + * @param integer $userId + * @param string $ip + * @since 1.22 + */ + public function getUserName( $userId, $ip ) { + return $userId > 0 ? $this->getProp( $userId, 'name' ) : $ip; + } + + /** * Preloads user names for given list of users. - * @param $userIds Array List of user IDs - * @param $options Array Option flags; include 'userpage' and 'usertalk' - * @param $caller String: the calling method + * @param array $userIds List of user IDs + * @param array $options Option flags; include 'userpage' and 'usertalk' + * @param string $caller the calling method */ public function doQuery( array $userIds, $options = array(), $caller = '' ) { wfProfileIn( __METHOD__ ); @@ -70,6 +81,8 @@ class UserCache { $usersToCheck = array(); $usersToQuery = array(); + $userIds = array_unique( $userIds ); + foreach ( $userIds as $userId ) { $userId = (int)$userId; if ( $userId <= 0 ) { @@ -124,8 +137,8 @@ class UserCache { * Check if a cache type is in $options and was not loaded for this user * * @param $uid integer user ID - * @param $type string Cache type - * @param $options Array Requested cache types + * @param string $type Cache type + * @param array $options Requested cache types * @return bool */ protected function queryNeeded( $uid, $type, array $options ) { |