Fix wrong content id used in building cache key (#4882)

This commit is contained in:
Yuriy Bakhtin 2021-02-17 13:00:14 +03:00 committed by GitHub
parent f70acfa8d7
commit c3667ccdd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@
- Fix #4850: New AuthClient method onSuccessLogin() not available on standard OAuths - Fix #4850: New AuthClient method onSuccessLogin() not available on standard OAuths
- Fix #4856: Allow to invite users to space with pending membership application - Fix #4856: Allow to invite users to space with pending membership application
- Fix #4869: Fix cached comment content in email notification - Fix #4869: Fix cached comment content in email notification
- Fix #4857: Fix wrong content id on building cache key
- Fix #4838: ProsemirrorRichText::replaceLinkExtension() not compatible with HumHub < 1.8 - Fix #4838: ProsemirrorRichText::replaceLinkExtension() not compatible with HumHub < 1.8
- Fix #4847: RichText::postProcess(null) throws error - Fix #4847: RichText::postProcess(null) throws error

View File

@ -12,6 +12,7 @@ use cebe\markdown\GithubMarkdown;
use humhub\components\ActiveRecord; use humhub\components\ActiveRecord;
use humhub\components\Event; use humhub\components\Event;
use humhub\libs\Html; use humhub\libs\Html;
use humhub\modules\content\components\ContentAddonActiveRecord;
use humhub\modules\content\interfaces\ContentOwner; use humhub\modules\content\interfaces\ContentOwner;
use humhub\modules\content\widgets\richtext\extensions\link\LinkParserBlock; use humhub\modules\content\widgets\richtext\extensions\link\LinkParserBlock;
use humhub\modules\content\widgets\richtext\extensions\link\RichTextLinkExtension; use humhub\modules\content\widgets\richtext\extensions\link\RichTextLinkExtension;
@ -169,7 +170,12 @@ abstract class BaseRichTextConverter extends GithubMarkdown
*/ */
public static function buildCacheKeyForContent(ContentOwner $content, $prefix = null) public static function buildCacheKeyForContent(ContentOwner $content, $prefix = null)
{ {
$result = 'content_'.$content->content->id; if ($content instanceof ContentAddonActiveRecord) {
// prevent cache key for comments to use the same cache key of original content
return static::buildCacheKeyForRecord($content);
}
$result = 'content_' . $content->content->id;
return $prefix ? $prefix.'_'.$result : $result; return $prefix ? $prefix.'_'.$result : $result;
} }

View File

@ -69,7 +69,7 @@ class MailContentEntry extends \yii\base\Widget
$content = RichTextToHtmlConverter::process($this->content->getContentDescription(), [ $content = RichTextToHtmlConverter::process($this->content->getContentDescription(), [
RichTextToHtmlConverter::OPTION_IMAGE_AS_URL => true, RichTextToHtmlConverter::OPTION_IMAGE_AS_URL => true,
RichTextToHtmlConverter::OPTION_LINK_AS_TEXT => true, RichTextToHtmlConverter::OPTION_LINK_AS_TEXT => true,
RichTextToHtmlConverter::OPTION_CACHE_KEY => RichTextToHtmlConverter::buildCacheKeyForContent($this->content, 'mail_entry_' . $this->content->getContentName() . '_' . $this->content->id), RichTextToHtmlConverter::OPTION_CACHE_KEY => RichTextToHtmlConverter::buildCacheKeyForContent($this->content, 'mail_entry'),
]); ]);
if(!$this->originator) { if(!$this->originator) {