Merge branch '5.2' into 5.3
authorAlexander Ebert <ebert@woltlab.com>
Mon, 23 Nov 2020 15:34:03 +0000 (16:34 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 23 Nov 2020 15:34:03 +0000 (16:34 +0100)
1  2 
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_orphanedComments.php

index f478ffccbaba6c8708ea69be469a6529c286552d,0000000000000000000000000000000000000000..7ab0dcb1a960a5655facad7fcf5061282e6e45c9
mode 100644,000000..100644
--- /dev/null
@@@ -1,29 -1,0 +1,28 @@@
- CommentHandler::getInstance()->deleteObjects(
-       "com.woltlab.wcf.moderation.queue",
-       $objectIDs
- );
 +<?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);
 +
++if (!empty($objectIDs)) {
++      CommentHandler::getInstance()->deleteObjects("com.woltlab.wcf.moderation.queue", $objectIDs);
++}