From: joshuaruesweg Date: Thu, 2 Sep 2021 09:35:18 +0000 (+0200) Subject: Delete `LikeUserRebuildDataWorker` X-Git-Tag: 5.5.0_Alpha_1~458 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e3ae784ddaaaa77721f96958c86bcdeb2381070;p=GitHub%2FWoltLab%2FWCF.git Delete `LikeUserRebuildDataWorker` Closes #4418 --- diff --git a/wcfsetup/install/files/lib/system/worker/LikeUserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/LikeUserRebuildDataWorker.class.php deleted file mode 100644 index dfab8f4883..0000000000 --- a/wcfsetup/install/files/lib/system/worker/LikeUserRebuildDataWorker.class.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @package WoltLabSuite\Core\System\Worker - * @deprecated since 5.2 (the worker has been removed) - * - * @method LikeObjectList getObjectList() - */ -class LikeUserRebuildDataWorker extends AbstractRebuildDataWorker -{ - /** - * @inheritDoc - */ - protected $objectListClassName = LikeObjectList::class; - - /** - * @inheritDoc - */ - protected $limit = 100; - - /** - * @inheritDoc - */ - protected function initObjectList() - { - parent::initObjectList(); - - $this->objectList->sqlOrderBy = 'like_object.likeObjectID'; - } - - /** - * @inheritDoc - */ - public function execute() - { - parent::execute(); - - if (!$this->loopCount) { - // reset cached users - $sql = "UPDATE wcf" . WCF_N . "_like_object - SET cachedUsers = NULL"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - } - - $sql = "SELECT userID - FROM wcf" . WCF_N . "_like - WHERE objectID = ? - AND objectTypeID = ? - AND likeValue = ? - ORDER BY time DESC"; - $statement = WCF::getDB()->prepareStatement($sql, 3); - $userData = $userIDs = []; - foreach ($this->objectList as $likeObject) { - $userData[$likeObject->likeObjectID] = []; - - $statement->execute([ - $likeObject->objectID, - $likeObject->objectTypeID, - Like::LIKE, - ]); - while ($row = $statement->fetchArray()) { - $userData[$likeObject->likeObjectID][] = $row['userID']; - $userIDs[] = $row['userID']; - } - } - - if (empty($userIDs)) { - return; - } - - // fetch usernames - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("userID IN (?)", [$userIDs]); - $sql = "SELECT userID, username - FROM wcf" . WCF_N . "_user - " . $conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - $usernames = $statement->fetchMap('userID', 'username'); - - // update like objects - $sql = "UPDATE wcf" . WCF_N . "_like_object - SET cachedUsers = ? - WHERE likeObjectID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - - WCF::getDB()->beginTransaction(); - foreach ($userData as $likeObjectID => $data) { - foreach ($data as &$value) { - $value = [ - 'userID' => $value, - 'username' => $usernames[$value], - ]; - } - unset($value); - - $statement->execute([ - \serialize($data), - $likeObjectID, - ]); - } - WCF::getDB()->commitTransaction(); - } -}