From: Matthias Schmidt Date: Thu, 4 Feb 2021 16:41:15 +0000 (+0100) Subject: Split subquery into multiple lines X-Git-Tag: 5.4.0_Alpha_1~309^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=94d12f754cb121d91de716f529f1554db4e9a89d;p=GitHub%2FWoltLab%2FWCF.git Split subquery into multiple lines --- diff --git a/wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php b/wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php index 238f142084..1e5c43fd2a 100644 --- a/wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php @@ -160,13 +160,21 @@ class ArticleListPage extends SortablePage } if (!empty($this->title)) { $this->objectList->getConditionBuilder()->add( - 'article.articleID IN (SELECT articleID FROM wcf' . WCF_N . '_article_content WHERE title LIKE ?)', + 'article.articleID IN ( + SELECT articleID + FROM wcf' . WCF_N . '_article_content + WHERE title LIKE ? + )', ['%' . $this->title . '%'] ); } if (!empty($this->content)) { $this->objectList->getConditionBuilder()->add( - 'article.articleID IN (SELECT articleID FROM wcf' . WCF_N . '_article_content WHERE content LIKE ?)', + 'article.articleID IN ( + SELECT articleID + FROM wcf' . WCF_N . '_article_content + WHERE content LIKE ? + )', ['%' . $this->content . '%'] ); } @@ -180,7 +188,16 @@ class ArticleListPage extends SortablePage } } - $this->objectList->sqlSelects = "(SELECT title FROM wcf" . WCF_N . "_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = " . WCF::getLanguage()->languageID . ") LIMIT 1) AS title"; + $this->objectList->sqlSelects = "( + SELECT title + FROM wcf" . WCF_N . "_article_content + WHERE articleID = article.articleID + AND ( + languageID IS NULL + OR languageID = " . WCF::getLanguage()->languageID . " + ) + LIMIT 1 + ) AS title"; if ($this->publicationStatus != -1) { $this->objectList->getConditionBuilder()->add('article.publicationStatus = ?', [$this->publicationStatus]); diff --git a/wcfsetup/install/files/lib/acp/page/BoxListPage.class.php b/wcfsetup/install/files/lib/acp/page/BoxListPage.class.php index 7a270b7237..6d29bd1f38 100644 --- a/wcfsetup/install/files/lib/acp/page/BoxListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/BoxListPage.class.php @@ -139,13 +139,21 @@ class BoxListPage extends SortablePage } if (!empty($this->title)) { $this->objectList->getConditionBuilder()->add( - 'box.boxID IN (SELECT boxID FROM wcf' . WCF_N . '_box_content WHERE title LIKE ?)', + 'box.boxID IN ( + SELECT boxID + FROM wcf' . WCF_N . '_box_content + WHERE title LIKE ? + )', ['%' . $this->title . '%'] ); } if (!empty($this->content)) { $this->objectList->getConditionBuilder()->add( - 'box.boxID IN (SELECT boxID FROM wcf' . WCF_N . '_box_content WHERE content LIKE ?)', + 'box.boxID IN ( + SELECT boxID + FROM wcf' . WCF_N . '_box_content + WHERE content LIKE ? + )', ['%' . $this->content . '%'] ); } diff --git a/wcfsetup/install/files/lib/acp/page/LabelGroupListPage.class.php b/wcfsetup/install/files/lib/acp/page/LabelGroupListPage.class.php index a1cc4028a4..ff1f68793a 100644 --- a/wcfsetup/install/files/lib/acp/page/LabelGroupListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/LabelGroupListPage.class.php @@ -101,7 +101,11 @@ class LabelGroupListPage extends SortablePage { parent::initObjectList(); - $this->objectList->sqlSelects .= '(SELECT COUNT(*) FROM wcf' . WCF_N . '_label WHERE groupID = label_group.groupID) AS labels'; + $this->objectList->sqlSelects .= '( + SELECT COUNT(*) + FROM wcf' . WCF_N . '_label + WHERE groupID = label_group.groupID + ) AS labels'; if ($this->groupName) { $languageItemList = new LanguageItemList(); diff --git a/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php b/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php index dec5cc3d42..0ced0140cd 100644 --- a/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php @@ -50,9 +50,20 @@ class LanguageListPage extends SortablePage { parent::initObjectList(); - $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf" . WCF_N . "_user user WHERE languageID = language.languageID) AS users,"; - $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf" . WCF_N . "_language_item WHERE languageID = language.languageID) AS variables,"; - $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf" . WCF_N . "_language_item WHERE languageID = language.languageID AND languageCustomItemValue IS NOT NULL) AS customVariables"; + $this->objectList->sqlSelects = "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_user user + WHERE languageID = language.languageID + ) AS users, ( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_language_item + WHERE languageID = language.languageID + ) AS variables, ( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_language_item + WHERE languageID = language.languageID + AND languageCustomItemValue IS NOT NULL + ) AS customVariables"; } /** diff --git a/wcfsetup/install/files/lib/acp/page/MenuListPage.class.php b/wcfsetup/install/files/lib/acp/page/MenuListPage.class.php index da36da147e..e6f6b25f80 100644 --- a/wcfsetup/install/files/lib/acp/page/MenuListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/MenuListPage.class.php @@ -55,6 +55,18 @@ class MenuListPage extends SortablePage { parent::initObjectList(); - $this->objectList->sqlSelects .= '(SELECT COUNT(*) FROM wcf' . WCF_N . '_menu_item WHERE menuID = menu.menuID) AS items, (SELECT position FROM wcf' . WCF_N . '_box WHERE menuID = menu.menuID) AS position, (SELECT showOrder FROM wcf' . WCF_N . '_box WHERE menuID = menu.menuID) AS showOrder'; + $this->objectList->sqlSelects .= '( + SELECT COUNT(*) + FROM wcf' . WCF_N . '_menu_item + WHERE menuID = menu.menuID + ) AS items, ( + SELECT position + FROM wcf' . WCF_N . '_box + WHERE menuID = menu.menuID + ) AS position, ( + SELECT showOrder + FROM wcf' . WCF_N . '_box + WHERE menuID = menu.menuID + ) AS showOrder'; } } diff --git a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php index b7af7f3948..7bb0b99022 100644 --- a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php @@ -157,13 +157,21 @@ class PageListPage extends SortablePage } if (!empty($this->title)) { $this->objectList->getConditionBuilder()->add( - 'page.pageID IN (SELECT pageID FROM wcf' . WCF_N . '_page_content WHERE title LIKE ?)', + 'page.pageID IN ( + SELECT pageID + FROM wcf' . WCF_N . '_page_content + WHERE title LIKE ? + )', ['%' . $this->title . '%'] ); } if (!empty($this->content)) { $this->objectList->getConditionBuilder()->add( - 'page.pageID IN (SELECT pageID FROM wcf' . WCF_N . '_page_content WHERE content LIKE ?)', + 'page.pageID IN ( + SELECT pageID + FROM wcf' . WCF_N . '_page_content + WHERE content LIKE ? + )', ['%' . $this->content . '%'] ); } diff --git a/wcfsetup/install/files/lib/acp/page/PaidSubscriptionTransactionLogListPage.class.php b/wcfsetup/install/files/lib/acp/page/PaidSubscriptionTransactionLogListPage.class.php index 8c330b2b22..52e3001cf8 100644 --- a/wcfsetup/install/files/lib/acp/page/PaidSubscriptionTransactionLogListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PaidSubscriptionTransactionLogListPage.class.php @@ -115,7 +115,11 @@ class PaidSubscriptionTransactionLogListPage extends SortablePage } if ($this->username) { $this->objectList->getConditionBuilder()->add( - 'paid_subscription_transaction_log.userID IN (SELECT userID FROM wcf' . WCF_N . '_user WHERE username LIKE ?)', + 'paid_subscription_transaction_log.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user + WHERE username LIKE ? + )', ['%' . $this->username . '%'] ); } diff --git a/wcfsetup/install/files/lib/acp/page/PaidSubscriptionUserListPage.class.php b/wcfsetup/install/files/lib/acp/page/PaidSubscriptionUserListPage.class.php index 8e3083ae96..d60b5a29aa 100644 --- a/wcfsetup/install/files/lib/acp/page/PaidSubscriptionUserListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PaidSubscriptionUserListPage.class.php @@ -86,7 +86,11 @@ class PaidSubscriptionUserListPage extends SortablePage if ($this->username) { $this->objectList->getConditionBuilder()->add( - 'paid_subscription_user.userID IN (SELECT userID FROM wcf' . WCF_N . '_user WHERE username LIKE ?)', + 'paid_subscription_user.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user + WHERE username LIKE ? + )', ['%' . $this->username . '%'] ); } diff --git a/wcfsetup/install/files/lib/acp/page/StyleListPage.class.php b/wcfsetup/install/files/lib/acp/page/StyleListPage.class.php index c26d9e1f78..63ac655b39 100644 --- a/wcfsetup/install/files/lib/acp/page/StyleListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/StyleListPage.class.php @@ -49,6 +49,10 @@ class StyleListPage extends MultipleLinkPage { parent::initObjectList(); - $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf" . WCF_N . "_user WHERE styleID = style.styleID) AS users"; + $this->objectList->sqlSelects = "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_user + WHERE styleID = style.styleID + ) AS users"; } } diff --git a/wcfsetup/install/files/lib/acp/page/TagListPage.class.php b/wcfsetup/install/files/lib/acp/page/TagListPage.class.php index 061b6e5492..f5b9532154 100644 --- a/wcfsetup/install/files/lib/acp/page/TagListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/TagListPage.class.php @@ -88,7 +88,11 @@ class TagListPage extends SortablePage { parent::initObjectList(); - $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf" . WCF_N . "_tag_to_object t2o WHERE t2o.tagID = tag.tagID) AS usageCount"; + $this->objectList->sqlSelects = "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_tag_to_object t2o + WHERE t2o.tagID = tag.tagID + ) AS usageCount"; $this->objectList->sqlSelects .= ", language.languageName, language.languageCode"; $this->objectList->sqlSelects .= ", synonym.name AS synonymName"; diff --git a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php index 270d742bfe..89a493c3e0 100755 --- a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php @@ -72,7 +72,11 @@ class UserGroupListPage extends SortablePage if (!empty($this->objectList->sqlSelects)) { $this->objectList->sqlSelects .= ','; } - $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf" . WCF_N . "_user_to_group WHERE groupID = user_group.groupID) AS members"; + $this->objectList->sqlSelects .= "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_user_to_group + WHERE groupID = user_group.groupID + ) AS members"; } /** diff --git a/wcfsetup/install/files/lib/acp/page/UserOptionCategoryListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserOptionCategoryListPage.class.php index 4c7977bfda..6055863ad7 100644 --- a/wcfsetup/install/files/lib/acp/page/UserOptionCategoryListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserOptionCategoryListPage.class.php @@ -49,7 +49,11 @@ class UserOptionCategoryListPage extends SortablePage { parent::initObjectList(); - $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf" . WCF_N . "_user_option WHERE categoryName = user_option_category.categoryName) AS userOptions"; + $this->objectList->sqlSelects = "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_user_option + WHERE categoryName = user_option_category.categoryName + ) AS userOptions"; $this->objectList->getConditionBuilder()->add('user_option_category.parentCategoryName = ?', ['profile']); } } diff --git a/wcfsetup/install/files/lib/acp/page/UserOptionListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserOptionListPage.class.php index 2f2795ca72..87650a129b 100644 --- a/wcfsetup/install/files/lib/acp/page/UserOptionListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserOptionListPage.class.php @@ -50,7 +50,11 @@ class UserOptionListPage extends SortablePage parent::initObjectList(); $this->objectList->getConditionBuilder()->add( - "option_table.categoryName IN (SELECT categoryName FROM wcf" . WCF_N . "_user_option_category WHERE parentCategoryName = ?)", + "option_table.categoryName IN ( + SELECT categoryName + FROM wcf" . WCF_N . "_user_option_category + WHERE parentCategoryName = ? + )", ['profile'] ); } diff --git a/wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php index ded23f0f43..af9e0ed545 100644 --- a/wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php @@ -106,7 +106,11 @@ class UserTrophyListPage extends SortablePage if ($this->username) { $this->objectList->getConditionBuilder()->add( - 'user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user WHERE username LIKE ?)', + 'user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user + WHERE username LIKE ? + )', ['%' . $this->username . '%'] ); } diff --git a/wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php b/wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php index 82c5c69565..faf134a949 100644 --- a/wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php +++ b/wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php @@ -52,7 +52,14 @@ class GroupedAttachmentList extends AttachmentList $this->getConditionBuilder()->add('attachment.objectTypeID = ?', [$this->objectType->objectTypeID]); $this->getConditionBuilder()->add( - '(SELECT embeddedObjectID FROM wcf' . WCF_N . '_message_embedded_object WHERE messageObjectTypeID = ? AND messageID = attachment.objectID AND embeddedObjectTypeID = ? AND embeddedObjectID = attachment.attachmentID) IS NULL', + '( + SELECT embeddedObjectID + FROM wcf' . WCF_N . '_message_embedded_object + WHERE messageObjectTypeID = ? + AND messageID = attachment.objectID + AND embeddedObjectTypeID = ? + AND embeddedObjectID = attachment.attachmentID + ) IS NULL', [ ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $objectType), ObjectTypeCache::getInstance()->getObjectTypeIDByName( diff --git a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php index 11a9357618..9d1bd4d3eb 100644 --- a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php +++ b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php @@ -287,7 +287,11 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction // get excluded packages $conditions = new PreparedStatementConditionBuilder(); $conditions->add( - "packageUpdateVersionID IN (SELECT packageUpdateVersionID FROM wcf" . WCF_N . "_package_update_version WHERE packageUpdateID = ?)", + "packageUpdateVersionID IN ( + SELECT packageUpdateVersionID + FROM wcf" . WCF_N . "_package_update_version + WHERE packageUpdateID = ? + )", [$packageUpdateID] ); $sql = "SELECT * diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerList.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerList.class.php index a9e2acb9d7..8ea6da949d 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerList.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerList.class.php @@ -32,7 +32,11 @@ class PackageUpdateServerList extends DatabaseObjectList if (!empty($this->sqlSelects)) { $this->sqlSelects .= ','; } - $this->sqlSelects .= "(SELECT COUNT(*) FROM wcf" . WCF_N . "_package_update WHERE packageUpdateServerID = " . $this->getDatabaseTableAlias() . ".packageUpdateServerID) AS packages"; + $this->sqlSelects .= "( + SELECT COUNT(*) + FROM wcf" . WCF_N . "_package_update + WHERE packageUpdateServerID = " . $this->getDatabaseTableAlias() . ".packageUpdateServerID + ) AS packages"; parent::readObjects(); } diff --git a/wcfsetup/install/files/lib/page/ArticleListPage.class.php b/wcfsetup/install/files/lib/page/ArticleListPage.class.php index 1750928a1f..c98f11982b 100644 --- a/wcfsetup/install/files/lib/page/ArticleListPage.class.php +++ b/wcfsetup/install/files/lib/page/ArticleListPage.class.php @@ -187,7 +187,16 @@ class ArticleListPage extends SortablePage $this->applyFilters(); if ($this->sortField === 'title') { - $this->objectList->sqlSelects = "(SELECT title FROM wcf" . WCF_N . "_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = " . WCF::getLanguage()->languageID . ") LIMIT 1) AS title"; + $this->objectList->sqlSelects = "( + SELECT title + FROM wcf" . WCF_N . "_article_content + WHERE articleID = article.articleID + AND ( + languageID IS NULL + OR languageID = " . WCF::getLanguage()->languageID . " + ) + LIMIT 1 + ) AS title"; } } @@ -210,7 +219,12 @@ class ArticleListPage extends SortablePage if (!empty($groupLabelIDs)) { $this->objectList->getConditionBuilder()->add( - 'article.articleID NOT IN (SELECT objectID FROM wcf' . WCF_N . '_label_object WHERE objectTypeID = ? AND labelID IN (?))', + 'article.articleID NOT IN ( + SELECT objectID + FROM wcf' . WCF_N . '_label_object + WHERE objectTypeID = ? + AND labelID IN (?) + )', [ $objectTypeID, $groupLabelIDs, @@ -219,7 +233,12 @@ class ArticleListPage extends SortablePage } } else { $this->objectList->getConditionBuilder()->add( - 'article.articleID IN (SELECT objectID FROM wcf' . WCF_N . '_label_object WHERE objectTypeID = ? AND labelID = ?)', + 'article.articleID IN ( + SELECT objectID + FROM wcf' . WCF_N . '_label_object + WHERE objectTypeID = ? + AND labelID = ? + )', [ $objectTypeID, $labelID, diff --git a/wcfsetup/install/files/lib/page/CategoryTrophyListPage.class.php b/wcfsetup/install/files/lib/page/CategoryTrophyListPage.class.php index 6d8d5ee889..0d11993c40 100644 --- a/wcfsetup/install/files/lib/page/CategoryTrophyListPage.class.php +++ b/wcfsetup/install/files/lib/page/CategoryTrophyListPage.class.php @@ -68,7 +68,11 @@ class CategoryTrophyListPage extends TrophyListPage { MultipleLinkPage::initObjectList(); - $this->objectList->sqlSelects = '(SELECT COUNT(*) FROM wcf' . WCF_N . '_user_trophy WHERE trophyID = trophy.trophyID) AS awarded'; + $this->objectList->sqlSelects = '( + SELECT COUNT(*) + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID = trophy.trophyID + ) AS awarded'; $this->objectList->getConditionBuilder()->add('isDisabled = ?', [0]); $this->objectList->getConditionBuilder()->add('categoryID = ?', [$this->categoryID]); } diff --git a/wcfsetup/install/files/lib/page/TrophyListPage.class.php b/wcfsetup/install/files/lib/page/TrophyListPage.class.php index 34097c15f8..54f5222d45 100644 --- a/wcfsetup/install/files/lib/page/TrophyListPage.class.php +++ b/wcfsetup/install/files/lib/page/TrophyListPage.class.php @@ -92,7 +92,11 @@ class TrophyListPage extends MultipleLinkPage { parent::initObjectList(); - $this->objectList->sqlSelects = '(SELECT COUNT(*) FROM wcf' . WCF_N . '_user_trophy WHERE trophyID = trophy.trophyID) AS awarded'; + $this->objectList->sqlSelects = '( + SELECT COUNT(*) + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID = trophy.trophyID + ) AS awarded'; $this->objectList->getConditionBuilder()->add('isDisabled = ?', [0]); $this->objectList->getConditionBuilder()->add('categoryID IN (?)', [ \array_map(static function ($category) { diff --git a/wcfsetup/install/files/lib/page/TrophyPage.class.php b/wcfsetup/install/files/lib/page/TrophyPage.class.php index f639ff2a25..521dbc75d0 100644 --- a/wcfsetup/install/files/lib/page/TrophyPage.class.php +++ b/wcfsetup/install/files/lib/page/TrophyPage.class.php @@ -145,15 +145,33 @@ class TrophyPage extends MultipleLinkPage $canViewTrophyDefaultValue = UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->defaultValue; if (!WCF::getUser()->userID) { - $this->objectList->getConditionBuilder()->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0)'); + $this->objectList->getConditionBuilder()->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0)'); } elseif (!WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) { $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR'); - $conditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE (COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0 OR COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 1))'); + $conditionBuilder->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE ( + COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 0 + OR COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 1 + ) + )'); $friendshipConditionBuilder = new PreparedStatementConditionBuilder(false); - $friendshipConditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 2)'); + $friendshipConditionBuilder->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE COALESCE(userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ', ' . $canViewTrophyDefaultValue . ') = 2 + )'); $friendshipConditionBuilder->add( - 'user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_follow WHERE followUserID = ?)', + 'user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_follow + WHERE followUserID = ? + )', [WCF::getUser()->userID] ); $conditionBuilder->add( diff --git a/wcfsetup/install/files/lib/system/box/StaffOnlineListBoxController.class.php b/wcfsetup/install/files/lib/system/box/StaffOnlineListBoxController.class.php index 68995bea98..f6d5a84fa8 100644 --- a/wcfsetup/install/files/lib/system/box/StaffOnlineListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/StaffOnlineListBoxController.class.php @@ -28,7 +28,15 @@ class StaffOnlineListBoxController extends AbstractDatabaseObjectListBoxControll { $objectList = new UsersOnlineList(); $objectList->getConditionBuilder()->add( - 'session.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_to_group WHERE groupID IN (SELECT groupID FROM wcf' . WCF_N . '_user_group WHERE showOnTeamPage = ?))', + 'session.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_to_group + WHERE groupID IN ( + SELECT groupID + FROM wcf' . WCF_N . '_user_group + WHERE showOnTeamPage = ? + ) + )', [1] ); diff --git a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php index ebec88354f..bb423c869f 100644 --- a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php @@ -87,15 +87,34 @@ class UserTrophyListBoxController extends AbstractDatabaseObjectListBoxControlle $list->getConditionBuilder()->add('category.isDisabled = ?', [0]); if (!WCF::getUser()->userID) { - $list->getConditionBuilder()->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0)'); + $list->getConditionBuilder()->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0 + )'); } elseif (!WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) { $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR'); - $conditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE (userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0 OR userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 1))'); + $conditionBuilder->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE ( + userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 0 + OR userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 1 + ) + )'); $friendshipConditionBuilder = new PreparedStatementConditionBuilder(false); - $friendshipConditionBuilder->add('user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_option_value WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 2)'); + $friendshipConditionBuilder->add('user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_option_value + WHERE userOption' . UserOptionCacheBuilder::getInstance()->getData()['options']['canViewTrophies']->optionID . ' = 2 + )'); $friendshipConditionBuilder->add( - 'user_trophy.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_follow WHERE followUserID = ?)', + 'user_trophy.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_follow + WHERE followUserID = ? + )', [WCF::getUser()->userID] ); $conditionBuilder->add( diff --git a/wcfsetup/install/files/lib/system/cache/builder/ArticleCategoryLabelCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ArticleCategoryLabelCacheBuilder.class.php index c42115e6a3..22604e8111 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/ArticleCategoryLabelCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/ArticleCategoryLabelCacheBuilder.class.php @@ -31,7 +31,11 @@ class ArticleCategoryLabelCacheBuilder extends AbstractCacheBuilder )->objectTypeID, ]); $conditionBuilder->add( - 'objectID IN (SELECT categoryID FROM wcf' . WCF_N . '_category WHERE objectTypeID = ?)', + 'objectID IN ( + SELECT categoryID + FROM wcf' . WCF_N . '_category + WHERE objectTypeID = ? + )', [CategoryHandler::getInstance()->getObjectTypeByName('com.woltlab.wcf.article.category')->objectTypeID] ); diff --git a/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php index b742b20d32..a0a2b1eced 100644 --- a/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php @@ -79,13 +79,23 @@ class UserGroupCondition extends AbstractMultipleFieldsCondition implements if (isset($conditionData['groupIDs'])) { $objectList->getConditionBuilder()->add( - $tableName . '.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_to_group WHERE groupID IN (?) GROUP BY userID HAVING COUNT(userID) = ?)', + $tableName . '.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_to_group + WHERE groupID IN (?) + GROUP BY userID + HAVING COUNT(userID) = ? + )', [$conditionData['groupIDs'], \count($conditionData['groupIDs'])] ); } if (isset($conditionData['notGroupIDs'])) { $objectList->getConditionBuilder()->add( - $tableName . '.userID NOT IN (SELECT userID FROM wcf' . WCF_N . '_user_to_group WHERE groupID IN (?))', + $tableName . '.userID NOT IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_to_group + WHERE groupID IN (?) + )', [$conditionData['notGroupIDs']] ); } diff --git a/wcfsetup/install/files/lib/system/condition/UserTrophyCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserTrophyCondition.class.php index 61bf81a26e..56fe1fa3b4 100644 --- a/wcfsetup/install/files/lib/system/condition/UserTrophyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserTrophyCondition.class.php @@ -75,13 +75,23 @@ class UserTrophyCondition extends AbstractMultipleFieldsCondition implements if (isset($conditionData['userTrophyIDs'])) { $objectList->getConditionBuilder()->add( - 'user_table.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_trophy WHERE trophyID IN (?) GROUP BY userID HAVING COUNT(DISTINCT trophyID) = ?)', + 'user_table.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID IN (?) + GROUP BY userID + HAVING COUNT(DISTINCT trophyID) = ? + )', [$conditionData['userTrophyIDs'], \count($conditionData['userTrophyIDs'])] ); } if (isset($conditionData['notUserTrophyIDs'])) { $objectList->getConditionBuilder()->add( - 'user_table.userID NOT IN (SELECT userID FROM wcf' . WCF_N . '_user_trophy WHERE trophyID IN (?))', + 'user_table.userID NOT IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID IN (?) + )', [$conditionData['notUserTrophyIDs']] ); } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index dc0a445568..8ddd35d255 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -757,7 +757,10 @@ class PackageInstallationNodeBuilder "package_installation_queue.parentQueueID = ?", [$this->installation->queue->queueID] ); - $queueList->getConditionBuilder()->add("package_installation_queue.queueID NOT IN (SELECT queueID FROM wcf" . WCF_N . "_package_installation_node)"); + $queueList->getConditionBuilder()->add("package_installation_queue.queueID NOT IN ( + SELECT queueID + FROM wcf" . WCF_N . "_package_installation_node + )"); $queueList->readObjects(); foreach ($queueList as $queue) { diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 349b797ceb..e52383e958 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -779,7 +779,10 @@ class PackageUpdateDispatcher extends SingletonFactory // get all update versions $conditions = new PreparedStatementConditionBuilder(); $conditions->add("pu.packageUpdateServerID IN (?)", [$packageUpdateServerIDs]); - $conditions->add("package IN (SELECT DISTINCT package FROM wcf" . WCF_N . "_package)"); + $conditions->add("package IN ( + SELECT DISTINCT package + FROM wcf" . WCF_N . "_package + )"); $sql = "SELECT pu.packageUpdateID, pu.packageUpdateServerID, pu.package, puv.packageUpdateVersionID, puv.packageDate, puv.filename, puv.packageVersion diff --git a/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php index 00d34e1491..d44f58f773 100644 --- a/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php @@ -54,9 +54,22 @@ class ArticlePageHandler extends AbstractLookupPageHandler implements IOnlineLoc public function lookup($searchString) { $articleList = new ViewableArticleList(); - $articleList->sqlSelects = "(SELECT title FROM wcf" . WCF_N . "_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = " . WCF::getLanguage()->languageID . ") LIMIT 1) AS title"; + $articleList->sqlSelects = "( + SELECT title + FROM wcf" . WCF_N . "_article_content + WHERE articleID = article.articleID + AND ( + languageID IS NULL + OR languageID = " . WCF::getLanguage()->languageID . " + ) + LIMIT 1 + ) AS title"; $articleList->getConditionBuilder()->add( - 'article.articleID IN (SELECT articleID FROM wcf' . WCF_N . '_article_content WHERE title LIKE ?)', + 'article.articleID IN ( + SELECT articleID + FROM wcf' . WCF_N . '_article_content + WHERE title LIKE ? + )', ['%' . $searchString . '%'] ); $articleList->sqlLimit = 10; diff --git a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php index 07dd292107..3413527567 100644 --- a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php +++ b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php @@ -142,7 +142,11 @@ class TrophyConditionHandler extends SingletonFactory // prevent multiple awards from a trophy for a user $userList->getConditionBuilder()->add( - 'user_table.userID NOT IN (SELECT userID FROM wcf' . WCF_N . '_user_trophy WHERE trophyID IN (?))', + 'user_table.userID NOT IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID IN (?) + )', [$trophy->trophyID] ); $userList->readObjectIDs(); @@ -211,7 +215,11 @@ class TrophyConditionHandler extends SingletonFactory // In order not to get all users who do not fulfill the conditions (in case of // doubt there can be many), we filter for users who have received the trophy. $userList->getConditionBuilder()->add( - 'user_table.userID IN (SELECT userID FROM wcf' . WCF_N . '_user_trophy WHERE trophyID IN (?))', + 'user_table.userID IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_trophy + WHERE trophyID IN (?) + )', [$trophy->trophyID] ); diff --git a/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentResponseUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentResponseUserActivityEvent.class.php index bc71620804..b19cbc4d6a 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentResponseUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentResponseUserActivityEvent.class.php @@ -31,7 +31,11 @@ class ArticleCommentResponseUserActivityEvent extends SingletonFactory implement if (!empty($this->commentObjectIDs)) { $articleList = new ViewableArticleList(); $articleList->getConditionBuilder()->add( - "article.articleID IN (SELECT articleID FROM wcf" . WCF_N . "_article_content WHERE articleContentID IN (?))", + "article.articleID IN ( + SELECT articleID + FROM wcf" . WCF_N . "_article_content + WHERE articleContentID IN (?) + )", [$this->commentObjectIDs] ); $articleList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentUserActivityEvent.class.php index 9fc3d53527..ad9dce97f7 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentUserActivityEvent.class.php @@ -44,7 +44,11 @@ class ArticleCommentUserActivityEvent extends SingletonFactory implements IUserA if (!empty($articleContentIDs)) { $articleList = new ViewableArticleList(); $articleList->getConditionBuilder()->add( - "article.articleID IN (SELECT articleID FROM wcf" . WCF_N . "_article_content WHERE articleContentID IN (?))", + "article.articleID IN ( + SELECT articleID + FROM wcf" . WCF_N . "_article_content + WHERE articleContentID IN (?) + )", [$articleContentIDs] ); $articleList->readObjects(); diff --git a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php index 3cfd76baad..d547331bfe 100644 --- a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php @@ -105,7 +105,11 @@ class UserGroupAssignmentHandler extends SingletonFactory { $userList = new UserList(); $userList->getConditionBuilder()->add( - 'user_table.userID NOT IN (SELECT userID FROM wcf' . WCF_N . '_user_to_group WHERE groupID = ?)', + 'user_table.userID NOT IN ( + SELECT userID + FROM wcf' . WCF_N . '_user_to_group + WHERE groupID = ? + )', [$assignment->groupID] ); if ($maxUsers !== null) { diff --git a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php index 951b3a379f..b1fa466c31 100644 --- a/wcfsetup/install/files/lib/system/worker/MailWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/MailWorker.class.php @@ -75,7 +75,11 @@ class MailWorker extends AbstractWorker if ($this->mailData['action'] == 'group') { $this->conditions->add( - "user.userID IN (SELECT userID FROM wcf" . WCF_N . "_user_to_group WHERE groupID IN (?))", + "user.userID IN ( + SELECT userID + FROM wcf" . WCF_N . "_user_to_group + WHERE groupID IN (?) + )", [$this->mailData['groupIDs']] ); }