From ef915e37e3d87219d229de48c31c350d51413ede Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 18 Mar 2013 15:03:43 -0700 Subject: [PATCH] Added UserCache::getUserName() convenience function. Change-Id: Ice6b5e8608927db588edb1e8458f7d74e53f1214 --- includes/cache/UserCache.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php index bfbacfaaa9..694c1a142c 100644 --- a/includes/cache/UserCache.php +++ b/includes/cache/UserCache.php @@ -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 -- 2.20.1