mirror of
https://github.com/humhub/humhub.git
synced 2025-04-20 23:21:54 +02:00
Fix comments list when comment is active from another parent comment (#7487)
* Fix comments list when comment is active from another parent comment * Update CHANGELOG.md
This commit is contained in:
parent
6b04a6a83e
commit
9a21276770
@ -4,6 +4,7 @@ HumHub Changelog
|
||||
1.17.3 (Unreleased)
|
||||
----------------------
|
||||
- Fix #7484: Use password type on the installation DB config form
|
||||
- Fix #7487: Fix comments list when comment is active from another parent comment
|
||||
|
||||
1.17.2 (April 7, 2025)
|
||||
----------------------
|
||||
|
@ -65,9 +65,7 @@ class Comments extends Widget
|
||||
{
|
||||
$objectModel = PolymorphicRelation::getObjectModel($this->object);
|
||||
$objectId = $this->object->getPrimaryKey();
|
||||
|
||||
$streamQuery = Yii::$app->request->getQueryParam('StreamQuery');
|
||||
$currentCommentId = empty($streamQuery['commentId']) ? null : $streamQuery['commentId'];
|
||||
$currentCommentId = $this->getCurrentCommentId();
|
||||
|
||||
// Count all Comments
|
||||
$commentCount = CommentModel::GetCommentCount($objectModel, $objectId);
|
||||
@ -101,4 +99,27 @@ class Comments extends Widget
|
||||
{
|
||||
return $this->isFullViewMode() ? $this->module->commentsBlockLoadSizeViewMode : $this->module->commentsBlockLoadSize;
|
||||
}
|
||||
|
||||
protected function getCurrentCommentId(): ?int
|
||||
{
|
||||
$streamQuery = Yii::$app->request->getQueryParam('StreamQuery');
|
||||
if (empty($streamQuery['commentId'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$currentCommentId = (int) $streamQuery['commentId'];
|
||||
|
||||
$currentComment = Yii::$app->runtimeCache->getOrSet('getCurrentComment' . $currentCommentId, function () use ($currentCommentId) {
|
||||
return CommentModel::findOne(['id' => $currentCommentId]);
|
||||
});
|
||||
|
||||
if (!$currentComment ||
|
||||
$currentComment->object_id !== $this->object?->id ||
|
||||
$currentComment->object_model !== get_class($this->object)) {
|
||||
// The current comment is from another parent object
|
||||
return null;
|
||||
}
|
||||
|
||||
return $currentCommentId;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user