UserCache::getUserName: Docs said @since 1.21, but not in REL1_21
[lhc/web/wiklou.git] / includes / cache / UserCache.php
index bfbacfa..6085f58 100644 (file)
@@ -58,6 +58,17 @@ class UserCache {
                        : false; // user does not exist?
        }
 
+       /**
+        * 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 array $userIds List of user IDs
@@ -70,6 +81,8 @@ class UserCache {
                $usersToCheck = array();
                $usersToQuery = array();
 
+               $userIds = array_unique( $userIds );
+
                foreach ( $userIds as $userId ) {
                        $userId = (int)$userId;
                        if ( $userId <= 0 ) {