From: Matthias Schmidt Date: Wed, 9 Jun 2021 13:16:18 +0000 (+0200) Subject: Load embedded objects for structured/viewable comment (response) lists X-Git-Tag: 5.5.0_Alpha_1~670^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cac5c3cd8977e383caa1203c64cebd1e185d6167;p=GitHub%2FWoltLab%2FWCF.git Load embedded objects for structured/viewable comment (response) lists --- diff --git a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php index 337ab41d6a..07b0330401 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php @@ -7,6 +7,7 @@ use wcf\data\comment\response\StructuredCommentResponse; use wcf\data\like\object\LikeObject; use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\comment\manager\ICommentManager; +use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; use wcf\system\reaction\ReactionHandler; /** @@ -110,7 +111,7 @@ class StructuredCommentList extends CommentList $canModerate = $this->commentManager->canModerate($this->objectTypeID, $this->objectID); // fetch response ids - $responseIDs = $userIDs = []; + $embeddedObjectIDs = $responseIDs = $userIDs = []; /** @var StructuredComment $comment */ foreach ($this->objects as $comment) { if (!$this->minCommentTime || $comment->time < $this->minCommentTime) { @@ -129,6 +130,10 @@ class StructuredCommentList extends CommentList $userIDs[] = $comment->userID; } + if ($comment->hasEmbeddedObjects) { + $embeddedObjectIDs[] = $comment->getObjectID(); + } + $comment->setIsDeletable($this->commentManager->canDeleteComment($comment->getDecoratedObject())); $comment->setIsEditable($this->commentManager->canEditComment($comment->getDecoratedObject())); } @@ -139,6 +144,7 @@ class StructuredCommentList extends CommentList $responseList->setObjectIDs(\array_keys($responseIDs)); $responseList->readObjects(); + $embeddedResponseIDs = []; foreach ($responseList as $response) { $response = new StructuredCommentResponse($response); @@ -155,6 +161,17 @@ class StructuredCommentList extends CommentList if ($response->userID) { $userIDs[] = $response->userID; } + + if ($response->hasEmbeddedObjects) { + $embeddedResponseIDs[] = $response->getObjectID(); + } + } + + if (!empty($embeddedResponseIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects( + 'com.woltlab.wcf.comment.response', + $embeddedResponseIDs + ); } } @@ -162,6 +179,13 @@ class StructuredCommentList extends CommentList if (!empty($userIDs)) { UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\array_unique($userIDs)); } + + if (!empty($embeddedObjectIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects( + 'com.woltlab.wcf.comment', + $embeddedObjectIDs + ); + } } /** diff --git a/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php b/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php index d5ce1f582f..c4e28e8dc7 100644 --- a/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php @@ -3,6 +3,7 @@ namespace wcf\data\comment; use wcf\system\cache\runtime\UserProfileRuntimeCache; +use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; /** * Represents a list of decorated comment objects. @@ -33,16 +34,27 @@ class ViewableCommentList extends CommentList parent::readObjects(); if (!empty($this->objects)) { - $userIDs = []; + $embeddedObjectIDs = $userIDs = []; foreach ($this->objects as $comment) { if ($comment->userID) { $userIDs[] = $comment->userID; } + + if ($comment->hasEmbeddedObjects) { + $embeddedObjectIDs[] = $comment->getObjectID(); + } } if (!empty($userIDs)) { UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } + + if (!empty($embeddedObjectIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects( + 'com.woltlab.wcf.comment', + $embeddedObjectIDs + ); + } } } } diff --git a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php index 6264d51d00..2d7f8cc863 100644 --- a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php @@ -6,6 +6,7 @@ use wcf\data\comment\Comment; use wcf\data\like\object\LikeObject; use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\comment\manager\ICommentManager; +use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; use wcf\system\reaction\ReactionHandler; /** @@ -77,13 +78,17 @@ class StructuredCommentResponseList extends CommentResponseList parent::readObjects(); // get user ids - $userIDs = []; + $embeddedObjectIDs = $userIDs = []; foreach ($this->objects as $response) { if (!$this->minResponseTime || $response->time < $this->minResponseTime) { $this->minResponseTime = $response->time; } $userIDs[] = $response->userID; + if ($response->hasEmbeddedObjects) { + $embeddedObjectIDs[] = $response->getObjectID(); + } + $response->setIsDeletable($this->commentManager->canDeleteResponse($response->getDecoratedObject())); $response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject())); } @@ -92,6 +97,13 @@ class StructuredCommentResponseList extends CommentResponseList if (!empty($userIDs)) { UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\array_unique($userIDs)); } + + if (!empty($embeddedObjectIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects( + 'com.woltlab.wcf.comment.response', + $embeddedObjectIDs + ); + } } /** diff --git a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php index 5c92591300..a9dba01d1f 100644 --- a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php @@ -3,6 +3,7 @@ namespace wcf\data\comment\response; use wcf\system\cache\runtime\UserProfileRuntimeCache; +use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; /** * Represents a list of decorated comment response objects. @@ -33,16 +34,27 @@ class ViewableCommentResponseList extends CommentResponseList parent::readObjects(); if (!empty($this->objects)) { - $userIDs = []; + $embeddedObjectIDs = $userIDs = []; foreach ($this->objects as $response) { if ($response->userID) { $userIDs[] = $response->userID; } + + if ($response->hasEmbeddedObjects) { + $embeddedObjectIDs[] = $response->getObjectID(); + } } if (!empty($userIDs)) { UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } + + if (!empty($embeddedObjectIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects( + 'com.woltlab.wcf.comment.response', + $embeddedObjectIDs + ); + } } } }