Use own statement to delete user activity events
authorJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 19 Dec 2019 12:42:37 +0000 (13:42 +0100)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 19 Dec 2019 12:42:43 +0000 (13:42 +0100)
For performance reasons, we use an own statement to delete likeable recent activity events.

wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2_deleteRecentActivity.php

index 5e3df84679ed37b31bc48dfb14eed2bdbd955a49..6cca64c4d8d49bde39f21aaf31a4e1eff345937a 100644 (file)
@@ -15,10 +15,17 @@ $definitionList->getConditionBuilder()->add('definitionName = ?', ['com.woltlab.
 $definitionList->readObjects();
 $definition = $definitionList->current();
 
-$recentActivityList = new \wcf\data\user\activity\event\UserActivityEventList();
-$recentActivityList->getConditionBuilder()->add("objectTypeID IN (SELECT objectTypeID FROM wcf". WCF_N ."_object_type WHERE objectType LIKE '%likeable%' AND definitionID = ?)", [$definition->definitionID]);
-$recentActivityList->readObjectIDs();
+$sql = "SELECT  objectTypeID
+       FROM    wcf". WCF_N ."_object_type
+       WHERE   objectType LIKE '%likeable%'
+       AND     definitionID = ?";
+$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+$statement->execute([$definition->definitionID]);
+$objectTypeIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
 
-if (count($recentActivityList->getObjectIDs())) {
-       \wcf\data\user\activity\event\UserActivityEventEditor::deleteAll($recentActivityList->getObjectIDs());
-}
+$conditionBuilder = new \wcf\system\database\util\PreparedStatementConditionBuilder();
+$conditionBuilder->add('objectTypeID IN (?)', [$objectTypeIDs]);
+
+$sql = "DELETE FROM wcf". WCF_N ."_user_activity_event ".$conditionBuilder;
+$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+$statement->execute($conditionBuilder->getParameters());