Split subquery into multiple lines
authorMatthias Schmidt <gravatronics@live.com>
Thu, 4 Feb 2021 16:41:15 +0000 (17:41 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 4 Feb 2021 16:41:15 +0000 (17:41 +0100)
34 files changed:
wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php
wcfsetup/install/files/lib/acp/page/BoxListPage.class.php
wcfsetup/install/files/lib/acp/page/LabelGroupListPage.class.php
wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php
wcfsetup/install/files/lib/acp/page/MenuListPage.class.php
wcfsetup/install/files/lib/acp/page/PageListPage.class.php
wcfsetup/install/files/lib/acp/page/PaidSubscriptionTransactionLogListPage.class.php
wcfsetup/install/files/lib/acp/page/PaidSubscriptionUserListPage.class.php
wcfsetup/install/files/lib/acp/page/StyleListPage.class.php
wcfsetup/install/files/lib/acp/page/TagListPage.class.php
wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php
wcfsetup/install/files/lib/acp/page/UserOptionCategoryListPage.class.php
wcfsetup/install/files/lib/acp/page/UserOptionListPage.class.php
wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php
wcfsetup/install/files/lib/data/attachment/GroupedAttachmentList.class.php
wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php
wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerList.class.php
wcfsetup/install/files/lib/page/ArticleListPage.class.php
wcfsetup/install/files/lib/page/CategoryTrophyListPage.class.php
wcfsetup/install/files/lib/page/TrophyListPage.class.php
wcfsetup/install/files/lib/page/TrophyPage.class.php
wcfsetup/install/files/lib/system/box/StaffOnlineListBoxController.class.php
wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php
wcfsetup/install/files/lib/system/cache/builder/ArticleCategoryLabelCacheBuilder.class.php
wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php
wcfsetup/install/files/lib/system/condition/UserTrophyCondition.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php
wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php
wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php
wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentResponseUserActivityEvent.class.php
wcfsetup/install/files/lib/system/user/activity/event/ArticleCommentUserActivityEvent.class.php
wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php
wcfsetup/install/files/lib/system/worker/MailWorker.class.php

index 238f1420849fbbfce6def5b13b6f4a2f03decbeb..1e5c43fd2ae449dbd3313d1588909024e92bea0b 100644 (file)
@@ -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]);
index 7a270b72376080724e045435f5199e52f3b43129..6d29bd1f38654c664ff9fdaf315a3d1a51f4982a 100644 (file)
@@ -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 . '%']
             );
         }
index a1cc4028a4771177dacce26ec45978c14f5de947..ff1f68793a565a7b01b19845766d8a1ab6bf2ada 100644 (file)
@@ -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();
index dec5cc3d42ce52234cdac1df541f92a388582a2c..0ced0140cdcbdb2eb6f4a2ea34b3096ace13be51 100644 (file)
@@ -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";
     }
 
     /**
index da36da147ec5bf33600cb8ab0fbd06e015b0b043..e6f6b25f808f6372eff72731090e33674c1f6a28 100644 (file)
@@ -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';
     }
 }
index b7af7f3948871a3541a938fbd82e5180c1f37489..7bb0b99022e2aa897cb0be9cda184f85d4f18ff6 100644 (file)
@@ -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 . '%']
             );
         }
index 8c330b2b221b058089b5b5a4670417baa90cf4ee..52e3001cf82c2bc99961dcebdfffbe465ffe9cec 100644 (file)
@@ -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 . '%']
             );
         }
index 8e3083ae96c534a331fc0937cb541007768ad54c..d60b5a29aa9781323b6f9846b7986e43f50d24e4 100644 (file)
@@ -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 . '%']
             );
         }
index c26d9e1f7876c488d88d8f7623bde16a8366a581..63ac655b39a300fe41423abf6412bd53542cbf5f 100644 (file)
@@ -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";
     }
 }
index 061b6e54923b79ac9c30354a042e0f4639ea8dd3..f5b9532154bb7bd938eee256174f9ad264b1fbed 100644 (file)
@@ -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";
 
index 270d742bfe70e00c2d0b48bfa53636ec9829f57e..89a493c3e0fb406a80b2398e88f4b2b804ca5124 100755 (executable)
@@ -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";
     }
 
     /**
index 4c7977bfda17b8180718dc7b9e11b2a33298b2ea..6055863ad71db29238ef8509789c465e5c333a56 100644 (file)
@@ -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']);
     }
 }
index 2f2795ca72da0ee3d3fb12404a7a61247aafd703..87650a129b3a43ddf075850f221bf198218530dc 100644 (file)
@@ -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']
         );
     }
index ded23f0f43853294b2c8e0db024184b7e2869b0c..af9e0ed5457430816ac9a9bb471971fd7d30b7ad 100644 (file)
@@ -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 . '%']
             );
         }
index 82c5c6956570100ebfe119cbfcc70e79298431ee..faf134a949639f952fe2d3e8ee36f1c88264dc7f 100644 (file)
@@ -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(
index 11a93576183f16048336c2cf88f5536439f8520d..9d1bd4d3eb6299660219fd2e72178e4bea07bd46 100644 (file)
@@ -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  *
index a9e2acb9d7bb87dbc7446a0fe4c4d916df5f32d0..8ea6da949d421de910ecb1591943ac3802c1bbef 100644 (file)
@@ -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();
     }
index 1750928a1f53aef9050868cf634d41f574bdc42e..c98f11982bc09d978e9f08daeff731ea3e78f562 100644 (file)
@@ -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,
index 6d8d5ee8891ae37c3356f205c2dfac693bb6aef4..0d11993c40426fc40c504b40d3ed4aa71a09e057 100644 (file)
@@ -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]);
     }
index 34097c15f899b5fb99e2fd3f2a4f57b65e277d4e..54f5222d454d674b8096fe8cae3f65b35c5a29c1 100644 (file)
@@ -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) {
index f639ff2a2564e8d429d9c0de512dd12360131b27..521dbc75d072757fad16d2b85e5a88257e917fea 100644 (file)
@@ -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(
index 68995bea980c19eba1a799cf453392534ac839c8..f6d5a84fa863a318ee89909234e98217d83c2a68 100644 (file)
@@ -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]
         );
 
index ebec88354fec9811075525a7a1803d108988779e..bb423c869fc04bd86e4eda6e8983e99e87c607db 100644 (file)
@@ -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(
index c42115e6a301c007368118040f501170ce1c3e4b..22604e8111084238deed42c5e67fedaec7e66402 100644 (file)
@@ -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]
         );
 
index b742b20d32bd5112972f91ba1eba3cb1c28a69fa..a0a2b1ecedbda830bfb710e1bdcfad6903182ac6 100644 (file)
@@ -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']]
             );
         }
index 61bf81a26e29639d9de5925a585dcfa6f63427e9..56fe1fa3b43bbff2ee126c74e4c9625869a4d4d8 100644 (file)
@@ -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']]
             );
         }
index dc0a445568b9b7baca93dc024974743415b05a9f..8ddd35d2554510482f067d5634aaff2e6320e9f3 100644 (file)
@@ -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) {
index 349b797cebf9825f3be938b7e1bbdeaffda83394..e52383e9586ccd1c3fc14a3daf84ad9a910a096b 100644 (file)
@@ -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
index 00d34e14912e2e17e1f80435b64a35528d217314..d44f58f773e6b8e5a2574c0a4726ae91676fcf66 100644 (file)
@@ -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;
index 07dd2921073506a1d1c93fede0f932d254b3eb20..34135275678daca30726189e0b3f2ec79905461a 100644 (file)
@@ -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]
         );
 
index bc71620804f5b40902ca25bfe164e9db1c4f1c04..b19cbc4d6ab799532a2791110dd978e629a3d20f 100644 (file)
@@ -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();
index 9fc3d53527c3ee904a01ab4a4c7f1676dfeb9c7c..ad9dce97f792f811e2eb48fdb3197a7972f83f50 100644 (file)
@@ -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();
index 3cfd76baad4d0fcf00721514913dc02233e3bf46..d547331bfecd37f6e10554a80081adac0f88e3ae 100644 (file)
@@ -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) {
index 951b3a379ffdf34d990ffb8cdc9700b714866514..b1fa466c31ad2fc879088b59161d8efb2a00879a 100644 (file)
@@ -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']]
                 );
             }