Merge "mw.ui: button: Update focus state"
[lhc/web/wiklou.git] / includes / UserRightsProxy.php
index e3655ce..1b9e4b6 100644 (file)
@@ -113,12 +113,24 @@ class UserRightsProxy {
         * @return null|UserRightsProxy
         */
        private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
+               global $wgSharedDB, $wgSharedTables;
+               // If the user table is shared, perform the user query on it,
+               // but don't pass it to the UserRightsProxy,
+               // as user rights are normally not shared.
+               if ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
+                       $userdb = self::getDB( $wgSharedDB, $ignoreInvalidDB );
+               } else {
+                       $userdb = self::getDB( $database, $ignoreInvalidDB );
+               }
+
                $db = self::getDB( $database, $ignoreInvalidDB );
-               if ( $db ) {
-                       $row = $db->selectRow( 'user',
+
+               if ( $db && $userdb ) {
+                       $row = $userdb->selectRow( 'user',
                                array( 'user_id', 'user_name' ),
                                array( $field => $value ),
                                __METHOD__ );
+
                        if ( $row !== false ) {
                                return new UserRightsProxy( $db, $database,
                                        $row->user_name,
@@ -200,6 +212,8 @@ class UserRightsProxy {
        /**
         * Replaces User::addUserGroup()
         * @param string $group
+        *
+        * @return bool
         */
        function addGroup( $group ) {
                $this->db->insert( 'user_groups',
@@ -209,11 +223,15 @@ class UserRightsProxy {
                        ),
                        __METHOD__,
                        array( 'IGNORE' ) );
+
+               return true;
        }
 
        /**
         * Replaces User::removeUserGroup()
         * @param string $group
+        *
+        * @return bool
         */
        function removeGroup( $group ) {
                $this->db->delete( 'user_groups',
@@ -222,6 +240,8 @@ class UserRightsProxy {
                                'ug_group' => $group,
                        ),
                        __METHOD__ );
+
+               return true;
        }
 
        /**