Force the removal of orphaned comments during the upgrade
authorAlexander Ebert <ebert@woltlab.com>
Sat, 21 Nov 2020 18:36:16 +0000 (19:36 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 21 Nov 2020 18:36:16 +0000 (19:36 +0100)
com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2.10_orphanedComments.php [deleted file]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_orphanedComments.php [new file with mode: 0644]

index 246a33392832234b9e67ac67b4824302cce01508..94949bc0b7d05265759eef743b6500a322653241 100644 (file)
@@ -93,6 +93,8 @@
                
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.3_fixActivationMethod.php</instruction>
                
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.3_orphanedComments.php</instruction>
+               
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.3_style.php</instruction>
                
                <instruction type="style" run="standalone">defaultStyle.tar</instruction>
        
        <!-- Run the option.xml update for 5.3.0 -> 5.3.1, due to the missing removal of external_link_rel_nofollow. -->
        <!-- Run update_com.woltlab.wcf_5.3.1_style.php for 5.3.0 -> 5.3.1 -->
-       <!-- Include `update_com.woltlab.wcf_5.2.10_orphanedComments.php` in the next update! -->
+       <!-- Include `update_com.woltlab.wcf_5.3_orphanedComments.php` in the next update! -->
        <!-- Add a note about the updated CSS in email_html.tpl to the release notes:
                https://github.com/WoltLab/WCF/commit/1ac55ad408d5bfab4f69714c6259cc5d09ceb344
                Administrators are highly encouraged to apply the CSS adjustments to their custom template version.
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2.10_orphanedComments.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2.10_orphanedComments.php
deleted file mode 100644 (file)
index f478ffc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-namespace wcf\acp;
-
-use wcf\data\object\type\ObjectTypeCache;
-use wcf\system\comment\CommentHandler;
-use wcf\system\WCF;
-
-// Earlier versions did remove moderation queues without taking care of
-// comments associated with them.
-$commentObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
-       "com.woltlab.wcf.comment.commentableContent",
-       "com.woltlab.wcf.moderation.queue"
-);
-
-$sql = "SELECT  DISTINCT objectID
-        FROM    wcf" . WCF_N . "_comment
-        WHERE   objectTypeID = ?
-        AND     objectID NOT IN (
-                        SELECT  queueID
-                        FROM    wcf" . WCF_N . "_moderation_queue
-                )";
-$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute([$commentObjectTypeID]);
-$objectIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
-
-CommentHandler::getInstance()->deleteObjects(
-       "com.woltlab.wcf.moderation.queue",
-       $objectIDs
-);
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_orphanedComments.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_orphanedComments.php
new file mode 100644 (file)
index 0000000..f478ffc
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace wcf\acp;
+
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\comment\CommentHandler;
+use wcf\system\WCF;
+
+// Earlier versions did remove moderation queues without taking care of
+// comments associated with them.
+$commentObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
+       "com.woltlab.wcf.comment.commentableContent",
+       "com.woltlab.wcf.moderation.queue"
+);
+
+$sql = "SELECT  DISTINCT objectID
+        FROM    wcf" . WCF_N . "_comment
+        WHERE   objectTypeID = ?
+        AND     objectID NOT IN (
+                        SELECT  queueID
+                        FROM    wcf" . WCF_N . "_moderation_queue
+                )";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute([$commentObjectTypeID]);
+$objectIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+
+CommentHandler::getInstance()->deleteObjects(
+       "com.woltlab.wcf.moderation.queue",
+       $objectIDs
+);