From d707135491aa8d94ca8acba02b67908f3643eb7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 15 Mar 2021 12:22:12 +0100 Subject: [PATCH] Refactor query generation in UserSearchForm::search() The `$sql` can easily be moved down, as it is only used in a single place. This allows us to directly embed the condition. see dec19b25cdf21b81d73c5897cd3c885d5ec62ef4 see #4078 --- .../install/files/lib/form/UserSearchForm.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/form/UserSearchForm.class.php b/wcfsetup/install/files/lib/form/UserSearchForm.class.php index a1cf604355..68e5795f16 100644 --- a/wcfsetup/install/files/lib/form/UserSearchForm.class.php +++ b/wcfsetup/install/files/lib/form/UserSearchForm.class.php @@ -171,10 +171,6 @@ class UserSearchForm extends UserOptionListForm protected function search() { $this->matches = []; - $sql = "SELECT user_table.userID - FROM wcf" . WCF_N . "_user user_table - LEFT JOIN wcf" . WCF_N . "_user_option_value option_value - ON option_value.userID = user_table.userID"; // build search condition $this->conditions = new PreparedStatementConditionBuilder(); @@ -190,8 +186,13 @@ class UserSearchForm extends UserOptionListForm return; } - // do search - $statement = WCF::getDB()->prepareStatement($sql . "\n". $this->conditions, $this->maxResults); + // perform search + $sql = "SELECT user_table.userID + FROM wcf" . WCF_N . "_user user_table + LEFT JOIN wcf" . WCF_N . "_user_option_value option_value + ON option_value.userID = user_table.userID + {$this->conditions}"; + $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults); $statement->execute($this->conditions->getParameters()); $this->matches = $statement->fetchAll(\PDO::FETCH_COLUMN); } -- 2.20.1