From 42adab7e99f92038e60be4eef1897e3925e632dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 19 Dec 2019 13:42:37 +0100 Subject: [PATCH] Use own statement to delete user activity events For performance reasons, we use an own statement to delete likeable recent activity events. --- ...m.woltlab.wcf_5.2_deleteRecentActivity.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2_deleteRecentActivity.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2_deleteRecentActivity.php index 5e3df84679..6cca64c4d8 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2_deleteRecentActivity.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.2_deleteRecentActivity.php @@ -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()); -- 2.20.1