From f91a03aa329f1e7c80049b395205ed2534d399e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 19 May 2012 20:49:50 +0200 Subject: [PATCH] Revert "Optimizing ChatRoom::getUsers()" This reverts commit f8193d10500da5155f9dcd8a18758d3edd70193e. --- file/lib/data/chat/room/ChatRoom.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index aed4fa5..1d2d831 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -135,7 +135,7 @@ public function getUsers() { $userIDs = array(); while ($userIDs[] = $stmt->fetchColumn()); - if (empty($userIDs)) return array(); + if (!count($userIDs)) return array(); $sql = "SELECT u.*, @@ -146,15 +146,16 @@ public function getUsers() { wcf".WCF_N."_user_storage s ON ( u.userID = s.userID - AND s.field = ? - AND s.packageID = ? + AND s.field = ? + AND s.packageID = ? ) WHERE - u.userID IN (?) + u.userID IN (".rtrim(str_repeat('?,', count($userIDs)), ',').") ORDER BY u.username ASC"; $stmt = WCF::getDB()->prepareStatement($sql); - $stmt->execute(array('away', $packageID, $userIDs)); + array_unshift($userIDs, 'away', $packageID); + $stmt->execute($userIDs); return $stmt->fetchObjects('\wcf\data\user\User'); }