Replace `->prepareStatement()` in workers
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Feb 2023 15:22:36 +0000 (16:22 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Feb 2023 15:22:36 +0000 (16:22 +0100)
files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php
files/lib/system/worker/ConversationMessageSearchIndexRebuildDataWorker.class.php
files/lib/system/worker/ConversationRebuildDataWorker.class.php

index f2dcc70cbb7c3bdc2c8c8b596fef4e9b49c323c7..77f033065391e4cf15540c15847c3dfceaf27776 100644 (file)
@@ -38,8 +38,8 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker
         if ($this->count === null) {
             $this->count = 0;
             $sql = "SELECT  MAX(messageID) AS messageID
-                    FROM    wcf" . WCF_N . "_conversation_message";
-            $statement = WCF::getDB()->prepareStatement($sql);
+                    FROM    wcf1_conversation_message";
+            $statement = WCF::getDB()->prepare($sql);
             $statement->execute();
             $row = $statement->fetchArray();
             if ($row !== false) {
@@ -82,10 +82,10 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker
         $attachmentObjectType = ObjectTypeCache::getInstance()
             ->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message');
         $sql = "SELECT  COUNT(*) AS attachments
-                FROM    wcf" . WCF_N . "_attachment
+                FROM    wcf1_attachment
                 WHERE   objectTypeID = ?
                     AND objectID = ?";
-        $attachmentStatement = WCF::getDB()->prepareStatement($sql);
+        $attachmentStatement = WCF::getDB()->prepare($sql);
 
         // retrieve permissions
         $userIDs = [];
@@ -136,13 +136,13 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker
             $updateData[$message->messageID] = $data;
         }
 
-        $sql = "UPDATE  wcf" . WCF_N . "_conversation_message
+        $sql = "UPDATE  wcf1_conversation_message
                 SET     attachments = ?,
                         message = ?,
                         enableHtml = ?,
                         hasEmbeddedObjects = ?
                 WHERE   messageID = ?";
-        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement = WCF::getDB()->prepare($sql);
 
         WCF::getDB()->beginTransaction();
         foreach ($updateData as $messageID => $data) {
index 6348f91d58734b07e1796b05ec9f7a40e3a515db..7972ef1fe11d83cea28673cbdc92352f23c21cbf 100644 (file)
@@ -31,8 +31,8 @@ final class ConversationMessageSearchIndexRebuildDataWorker extends AbstractRebu
         if ($this->count === null) {
             $this->count = 0;
             $sql = "SELECT  MAX(messageID) AS messageID
-                    FROM    wcf" . WCF_N . "_conversation_message";
-            $statement = WCF::getDB()->prepareStatement($sql);
+                    FROM    wcf1_conversation_message";
+            $statement = WCF::getDB()->prepare($sql);
             $statement->execute();
             $row = $statement->fetchArray();
             if ($row !== false) {
index 5b6dedc34dc4e0d5ba3439c6a4ba9a2ba0e17a97..0b104101ae2b791d341d8eceb7e82e3782d96dd8 100644 (file)
@@ -32,8 +32,8 @@ class ConversationRebuildDataWorker extends AbstractRebuildDataWorker
         if ($this->count === null) {
             $this->count = 0;
             $sql = "SELECT  MAX(conversationID) AS conversationID
-                    FROM    wcf" . WCF_N . "_conversation";
-            $statement = WCF::getDB()->prepareStatement($sql);
+                    FROM    wcf1_conversation";
+            $statement = WCF::getDB()->prepare($sql);
             $statement->execute();
             $row = $statement->fetchArray();
             if ($row !== false) {
@@ -65,43 +65,43 @@ class ConversationRebuildDataWorker extends AbstractRebuildDataWorker
 
         // prepare statements
         $sql = "SELECT      messageID, time, userID, username
-                FROM        wcf" . WCF_N . "_conversation_message
+                FROM        wcf1_conversation_message
                 WHERE       conversationID = ?
                 ORDER BY    time";
-        $firstMessageStatement = WCF::getDB()->prepareStatement($sql, 1);
+        $firstMessageStatement = WCF::getDB()->prepare($sql, 1);
         $sql = "SELECT      time, userID, username
-                FROM        wcf" . WCF_N . "_conversation_message
+                FROM        wcf1_conversation_message
                 WHERE       conversationID = ?
                 ORDER BY    time DESC";
-        $lastMessageStatement = WCF::getDB()->prepareStatement($sql, 1);
+        $lastMessageStatement = WCF::getDB()->prepare($sql, 1);
         $sql = "SELECT  COUNT(*) AS messages,
                         SUM(attachments) AS attachments
-                FROM    wcf" . WCF_N . "_conversation_message
+                FROM    wcf1_conversation_message
                 WHERE   conversationID = ?";
-        $statsStatement = WCF::getDB()->prepareStatement($sql);
+        $statsStatement = WCF::getDB()->prepare($sql);
         $sql = "SELECT  COUNT(*) AS participants
-                FROM    wcf" . WCF_N . "_conversation_to_user conversation_to_user
+                FROM    wcf1_conversation_to_user conversation_to_user
                 WHERE   conversation_to_user.conversationID = ?
                     AND conversation_to_user.hideConversation <> ?
                     AND conversation_to_user.participantID <> ?
                     AND conversation_to_user.isInvisible = ?";
-        $participantCounterStatement = WCF::getDB()->prepareStatement($sql);
+        $participantCounterStatement = WCF::getDB()->prepare($sql);
         $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
+                FROM        wcf1_conversation_to_user conversation_to_user
+                LEFT JOIN   wcf1_user user_table
                 ON          user_table.userID = conversation_to_user.participantID
                 WHERE       conversation_to_user.conversationID = ?
                         AND conversation_to_user.participantID <> ?
                         AND conversation_to_user.isInvisible = ?
                 ORDER BY    user_table.username";
-        $participantStatement = WCF::getDB()->prepareStatement($sql, 5);
+        $participantStatement = WCF::getDB()->prepare($sql, 5);
 
         $sql = "SELECT  COUNT(*) AS participants
-                FROM    wcf" . WCF_N . "_conversation_to_user
+                FROM    wcf1_conversation_to_user
                 WHERE   conversationID = ?
                     AND hideConversation <> ?
                     AND participantID IS NOT NULL";
-        $existingParticipantStatement = WCF::getDB()->prepareStatement($sql);
+        $existingParticipantStatement = WCF::getDB()->prepare($sql);
 
         $obsoleteConversations = [];
         $updateData = [];
@@ -181,7 +181,7 @@ class ConversationRebuildDataWorker extends AbstractRebuildDataWorker
             $updateData[$conversation->conversationID] = $data;
         }
 
-        $sql = "UPDATE  wcf" . WCF_N . "_conversation
+        $sql = "UPDATE  wcf1_conversation
                 SET     firstMessageID = ?,
                         lastPostTime = ?,
                         lastPosterID = ?,
@@ -193,7 +193,7 @@ class ConversationRebuildDataWorker extends AbstractRebuildDataWorker
                         participants = ?,
                         participantSummary = ?
                 WHERE   conversationID = ?";
-        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement = WCF::getDB()->prepare($sql);
 
         WCF::getDB()->beginTransaction();
         foreach ($updateData as $conversationID => $data) {