jenkins-bot has submitted this change and it was merged.

Change subject: Add CentralAuthUser::newFromId()
......................................................................


Add CentralAuthUser::newFromId()

Change-Id: Ic824b649fac48b627daf7c9b91a3c91cdea38d8c
---
M CentralAuthUser.php
1 file changed, 21 insertions(+), 0 deletions(-)

Approvals:
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CentralAuthUser.php b/CentralAuthUser.php
index 0d4d395..49c82e2 100644
--- a/CentralAuthUser.php
+++ b/CentralAuthUser.php
@@ -111,6 +111,27 @@
        }
 
        /**
+        * Get a CentralAuthUser object from a user's id
+        *
+        * @param int $id
+        * @return CentralAuthUser|bool false if no user exists with that id
+        */
+       public static function newFromId( $id ) {
+               $name = self::getCentralSlaveDB()->selectField(
+                       'globaluser',
+                       'gu_name',
+                       array( 'gu_id' => $id ),
+                       __METHOD__
+               );
+
+               if ( $name ) {
+                       return new CentralAuthUser( $name );
+               } else {
+                       return false;
+               }
+       }
+
+       /**
         * Create a CentralAuthUser object from a joined globaluser/localuser 
row
         *
         * @param $row ResultWrapper|object

-- 
To view, visit https://gerrit.wikimedia.org/r/159387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic824b649fac48b627daf7c9b91a3c91cdea38d8c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to