Made User::getFormerGroups load properly
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 30 Mar 2015 18:13:46 +0000 (11:13 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 30 Mar 2015 18:13:46 +0000 (11:13 -0700)
Change-Id: I5c752f9446ef78f08c457e9758ebf9e0b79a0c37

includes/User.php

index 7f30263..ffe1d56 100644 (file)
@@ -3038,8 +3038,12 @@ class User implements IDBAccessObject {
         * @return array Names of the groups the user has belonged to.
         */
        public function getFormerGroups() {
+               $this->load();
+
                if ( is_null( $this->mFormerGroups ) ) {
-                       $dbr = wfGetDB( DB_MASTER );
+                       $dbr = ( $this->queryFlagsUsed & self::READ_LATEST )
+                               ? wfGetDB( DB_MASTER )
+                               : wfGetDB( DB_SLAVE );
                        $res = $dbr->select( 'user_former_groups',
                                array( 'ufg_group' ),
                                array( 'ufg_user' => $this->mId ),
@@ -3049,6 +3053,7 @@ class User implements IDBAccessObject {
                                $this->mFormerGroups[] = $row->ufg_group;
                        }
                }
+
                return $this->mFormerGroups;
        }