Merge "objectcache: add example use case to WANObjectCache::getMultiCheckKeyTime()"
[lhc/web/wiklou.git] / includes / user / UserRightsProxy.php
index 23c2177..3c2731a 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Cut-down copy of User interface for local-interwiki-database
  * user rights manipulation.
@@ -27,8 +29,6 @@
 class UserRightsProxy {
 
        /**
-        * Constructor.
-        *
         * @see newFromId()
         * @see newFromName()
         * @param IDatabase $db Db connection
@@ -198,15 +198,7 @@ class UserRightsProxy {
         * @return array
         */
        function getGroups() {
-               $res = $this->db->select( 'user_groups',
-                       [ 'ug_group' ],
-                       [ 'ug_user' => $this->id ],
-                       __METHOD__ );
-               $groups = [];
-               foreach ( $res as $row ) {
-                       $groups[] = $row->ug_group;
-               }
-               return $groups;
+               return array_keys( self::getGroupMemberships() );
        }
 
        /**
@@ -216,15 +208,7 @@ class UserRightsProxy {
         * @since 1.29
         */
        function getGroupMemberships() {
-               $res = $this->db->select( 'user_groups',
-                       UserGroupMembership::selectFields(),
-                       [ 'ug_user' => $this->id ],
-                       __METHOD__ );
-               $ugms = [];
-               foreach ( $res as $row ) {
-                       $ugms[$row->ug_group] = UserGroupMembership::newFromRow( $row );
-               }
-               return $ugms;
+               return UserGroupMembership::getMembershipsForUser( $this->id, $this->db );
        }
 
        /**
@@ -293,11 +277,11 @@ class UserRightsProxy {
                        __METHOD__
                );
 
-               $wikiId = $this->db->getWikiID();
+               $domainId = $this->db->getDomainID();
                $userId = $this->id;
                $this->db->onTransactionPreCommitOrIdle(
-                       function () use ( $wikiId, $userId ) {
-                               User::purge( $wikiId, $userId );
+                       function () use ( $domainId, $userId ) {
+                               User::purge( $domainId, $userId );
                        },
                        __METHOD__
                );