Remove unnecessary parentheses around join conditions
authorMatthias Schmidt <gravatronics@live.com>
Thu, 4 Feb 2021 13:11:44 +0000 (14:11 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 4 Feb 2021 13:11:44 +0000 (14:11 +0100)
files/lib/data/conversation/Conversation.class.php
files/lib/data/conversation/ConversationAction.class.php
files/lib/data/conversation/ConversationParticipantList.class.php
files/lib/data/conversation/UserConversationList.class.php
files/lib/data/conversation/message/SearchResultConversationMessageList.class.php
files/lib/page/ConversationFeedPage.class.php
files/lib/system/search/ConversationMessageSearch.class.php
files/lib/system/worker/ConversationRebuildDataWorker.class.php

index 65e3805d6f1929149d63240f138dbc86325b80d2..4c306062aee646d1ab4d878b17534aab554ad46f 100644 (file)
@@ -196,10 +196,8 @@ class Conversation extends DatabaseObject implements IPopoverObject, IRouteContr
         $sql = "SELECT      conversation_to_user.*, conversation.*
                 FROM        wcf" . WCF_N . "_conversation conversation
                 LEFT JOIN   wcf" . WCF_N . "_conversation_to_user conversation_to_user
-                ON          (
-                                conversation_to_user.participantID = ?
-                                AND conversation_to_user.conversationID = conversation.conversationID
-                            )
+                ON          conversation_to_user.participantID = ?
+                        AND conversation_to_user.conversationID = conversation.conversationID
                 WHERE       conversation.conversationID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute([$userID, $conversationID]);
@@ -223,10 +221,8 @@ class Conversation extends DatabaseObject implements IPopoverObject, IRouteContr
         $sql = "SELECT      conversation_to_user.*, conversation.*
                 FROM        wcf" . WCF_N . "_conversation conversation
                 LEFT JOIN   wcf" . WCF_N . "_conversation_to_user conversation_to_user
-                ON          (
-                                conversation_to_user.participantID = " . $userID . "
-                                AND conversation_to_user.conversationID = conversation.conversationID
-                            )
+                ON          conversation_to_user.participantID = " . $userID . "
+                        AND conversation_to_user.conversationID = conversation.conversationID
                 " . $conditionBuilder;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
@@ -393,7 +389,7 @@ class Conversation extends DatabaseObject implements IPopoverObject, IRouteContr
         $sql = "SELECT      user_table.username
                 FROM        wcf" . WCF_N . "_conversation_to_user conversation_to_user
                 LEFT JOIN   wcf" . WCF_N . "_user user_table
-                ON          (user_table.userID = conversation_to_user.participantID)
+                ON          user_table.userID = conversation_to_user.participantID
                 " . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
index 2f58879dff7e1508930d9772350f9addf35fcc7e..440eea26d2cf577cbb1c1b1859050ccf1922ac78 100644 (file)
@@ -756,11 +756,9 @@ class ConversationAction extends AbstractDatabaseObjectAction implements
             $sql = "SELECT      DISTINCT conversation.conversationID
                     FROM        wcf" . WCF_N . "_conversation conversation
                     LEFT JOIN   wcf" . WCF_N . "_conversation_to_user conversation_to_user
-                    ON          (
-                                    conversation_to_user.conversationID = conversation.conversationID
-                                    AND conversation_to_user.hideConversation <> " . Conversation::STATE_LEFT . "
-                                    AND conversation_to_user.participantID IS NOT NULL
-                                )
+                    ON          conversation_to_user.conversationID = conversation.conversationID
+                            AND conversation_to_user.hideConversation <> " . Conversation::STATE_LEFT . "
+                            AND conversation_to_user.participantID IS NOT NULL
                     " . $conditionBuilder;
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute($conditionBuilder->getParameters());
index 2ce263b477cd6940f17405ff44564abca88f86d7..d19c5282ccd85e8b97fcb7ea1aef4d60202563cd 100644 (file)
@@ -52,13 +52,13 @@ class ConversationParticipantList extends UserProfileList
                 );
             }
         }
-        $this->sqlConditionJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON (user_table.userID = conversation_to_user.participantID)";
+        $this->sqlConditionJoins .= " LEFT JOIN wcf" . WCF_N . "_user user_table ON user_table.userID = conversation_to_user.participantID";
 
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects = 'conversation_to_user.*';
-        $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_conversation_to_user conversation_to_user ON (conversation_to_user.participantID = user_table.userID AND conversation_to_user.conversationID = " . $conversationID . ")";
+        $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_conversation_to_user conversation_to_user ON conversation_to_user.participantID = user_table.userID AND conversation_to_user.conversationID = " . $conversationID;
     }
 
     /**
index 46a40fc4b823c18a674e195a4037ca9434ce97ae..1083c5fa5ab9c507f17590441286114af42477a4 100644 (file)
@@ -67,7 +67,7 @@ class UserConversationList extends ConversationList
             $this->getConditionBuilder()->add('conversation_to_user.participantID = ?', [$userID]);
             $this->getConditionBuilder()
                 ->add('conversation_to_user.hideConversation = ?', [$this->filter == 'hidden' ? 1 : 0]);
-            $this->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_conversation conversation ON (conversation.conversationID = conversation_to_user.conversationID)";
+            $this->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_conversation conversation ON conversation.conversationID = conversation_to_user.conversationID";
             if ($this->filter == 'outbox') {
                 $this->getConditionBuilder()->add('conversation.userID = ?', [$userID]);
             }
@@ -84,14 +84,14 @@ class UserConversationList extends ConversationList
 
         // own posts
         $this->sqlSelects = "DISTINCT conversation_message.userID AS ownPosts";
-        $this->sqlJoins = "LEFT JOIN wcf" . WCF_N . "_conversation_message conversation_message ON (conversation_message.conversationID = conversation.conversationID AND conversation_message.userID = " . $userID . ")";
+        $this->sqlJoins = "LEFT JOIN wcf" . WCF_N . "_conversation_message conversation_message ON conversation_message.conversationID = conversation.conversationID AND conversation_message.userID = " . $userID;
 
         // user info
         if (!empty($this->sqlSelects)) {
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= "conversation_to_user.*";
-        $this->sqlJoins .= "LEFT JOIN wcf" . WCF_N . "_conversation_to_user conversation_to_user ON (conversation_to_user.participantID = " . $userID . " AND conversation_to_user.conversationID = conversation.conversationID)";
+        $this->sqlJoins .= "LEFT JOIN wcf" . WCF_N . "_conversation_to_user conversation_to_user ON conversation_to_user.participantID = " . $userID . " AND conversation_to_user.conversationID = conversation.conversationID";
 
         if ($this->filter !== 'draft') {
             $this->sqlSelects .= ", conversation.*, CASE WHEN conversation_to_user.leftAt <> 0 THEN conversation_to_user.leftAt ELSE conversation.lastPostTime END AS lastPostTime";
index db24c7e082304fe7bcfd09f0fc335e1ef61d2447..ee6899413fb47d3d1879fc35229ee8bbe6201059 100644 (file)
@@ -33,6 +33,6 @@ class SearchResultConversationMessageList extends SimplifiedViewableConversation
             $this->sqlSelects .= ',';
         }
         $this->sqlSelects .= 'conversation.subject';
-        $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_conversation conversation ON (conversation.conversationID = conversation_message.conversationID)";
+        $this->sqlJoins .= " LEFT JOIN wcf" . WCF_N . "_conversation conversation ON conversation.conversationID = conversation_message.conversationID";
     }
 }
index 1dde9a2e3960c88032043adb819e035a3bd30806..5338093f761eb6e460d5332d112c2e1cf4635225 100644 (file)
@@ -30,7 +30,7 @@ class ConversationFeedPage extends AbstractFeedPage
         $this->items = new FeedConversationList();
         $this->items->getConditionBuilder()->add('conversation_to_user.participantID = ?', [WCF::getUser()->userID]);
         $this->items->getConditionBuilder()->add('conversation_to_user.hideConversation = ?', [0]);
-        $this->items->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_conversation conversation ON (conversation.conversationID = conversation_to_user.conversationID)";
+        $this->items->sqlConditionJoins = "LEFT JOIN wcf" . WCF_N . "_conversation conversation ON conversation.conversationID = conversation_to_user.conversationID";
         $this->items->sqlLimit = 20;
         $this->items->readObjects();
 
index c19eef852a669ad048e0680b8e28fb4d4090ed6a..e254cd066516c4981c7b468ceecd34b4abd4038e 100644 (file)
@@ -77,12 +77,10 @@ class ConversationMessageSearch extends AbstractSearchableObjectType
     public function getJoins()
     {
         return "    JOIN        wcf" . WCF_N . "_conversation_to_user conversation_to_user
-                    ON          (
-                                    conversation_to_user.participantID = " . WCF::getUser()->userID . "
-                                    AND conversation_to_user.conversationID = " . $this->getTableName() . ".conversationID
-                                )
+                    ON          conversation_to_user.participantID = " . WCF::getUser()->userID . "
+                            AND conversation_to_user.conversationID = " . $this->getTableName() . ".conversationID
                     LEFT JOIN   wcf" . WCF_N . "_conversation conversation
-                    ON          (conversation.conversationID = " . $this->getTableName() . ".conversationID)";
+                    ON          conversation.conversationID = " . $this->getTableName() . ".conversationID";
     }
 
     /**
index 7d6b20e04e1e770ca166a70419fb7611a49d7a42..01b3a393d1e2f64f7071f9c8315ab7579a6ab177 100644 (file)
@@ -90,7 +90,7 @@ class ConversationRebuildDataWorker extends AbstractRebuildDataWorker
         $sql = "SELECT      conversation_to_user.participantID AS userID, conversation_to_user.hideConversation, user_table.username
                 FROM        wcf" . WCF_N . "_conversation_to_user conversation_to_user
                 LEFT JOIN   wcf" . WCF_N . "_user user_table
-                ON          (user_table.userID = conversation_to_user.participantID)
+                ON          user_table.userID = conversation_to_user.participantID
                 WHERE       conversation_to_user.conversationID = ?
                         AND conversation_to_user.participantID <> ?
                         AND conversation_to_user.isInvisible = ?