Added UserCache::getUserName() convenience function.
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 18 Mar 2013 22:03:43 +0000 (15:03 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 18 Mar 2013 22:03:49 +0000 (15:03 -0700)
Change-Id: Ice6b5e8608927db588edb1e8458f7d74e53f1214

includes/cache/UserCache.php

index bfbacfa..694c1a1 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.21
+        */
+       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