Preventing an unnecessary query to fetch user profiles
authorAlexander Ebert <ebert@woltlab.com>
Tue, 1 Jul 2014 12:09:57 +0000 (14:09 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 1 Jul 2014 12:09:57 +0000 (14:09 +0200)
The user profile list attempts to read the object ids prior to reading the actual users which is a good idea if you're fetching users based upon multiple criteria.

When reading user profiles by user id we already know the user ids and can directly pass them to avoid the query since the result is most likely the same.

wcfsetup/install/files/lib/data/user/UserProfile.class.php

index 9f7824c5bbc615d033aee6000a18cf3f94be6ce3..187c5fa518770f8cdc053bebe78553960cb9ef3d 100644 (file)
@@ -380,7 +380,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider
                
                if (!empty($userIDs)) {
                        $userList = new UserProfileList();
-                       $userList->getConditionBuilder()->add("user_table.userID IN (?)", array($userIDs));
+                       $userList->setObjectIDs($userIDs);
                        $userList->readObjects();
                        
                        foreach ($userList as $user) {