From 3af7b77d40ed93c95cebb22004ab745bf69683e2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 6 Jul 2021 13:08:46 +0200 Subject: [PATCH] Fixed missing language version for embedded articles --- ...icleMessageEmbeddedObjectHandler.class.php | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php index a7b808392b..4d53b9fbdc 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/ArticleMessageEmbeddedObjectHandler.class.php @@ -4,6 +4,8 @@ namespace wcf\system\message\embedded\object; use wcf\data\article\AccessibleArticleList; use wcf\data\article\Article; +use wcf\data\article\content\ViewableArticleContentList; +use wcf\system\cache\runtime\ViewableArticleRuntimeCache; use wcf\system\html\input\HtmlInputProcessor; /** @@ -36,11 +38,33 @@ class ArticleMessageEmbeddedObjectHandler extends AbstractSimpleMessageEmbeddedO */ public function loadObjects(array $objectIDs) { - $articleList = new AccessibleArticleList(); - $articleList->getConditionBuilder()->add('article.articleID IN (?)', [$objectIDs]); - $articleList->readObjects(); + $viewableArticles = ViewableArticleRuntimeCache::getInstance()->getObjects($objectIDs); + $contentLanguageID = MessageEmbeddedObjectManager::getInstance()->getContentLanguageID(); + if ($contentLanguageID !== null) { + $articleIDs = []; + foreach ($viewableArticles as $article) { + if ( + $article !== null + && $article->getArticleContent()->languageID + && $article->getArticleContent()->languageID != $contentLanguageID + ) { + $articleIDs[] = $article->articleID; + } + } + + if (!empty($articleIDs)) { + $list = new ViewableArticleContentList(); + $list->getConditionBuilder()->add("articleID IN (?)", [$articleIDs]); + $list->getConditionBuilder()->add("languageID = ?", [$contentLanguageID]); + $list->readObjects(); + + foreach ($list->getObjects() as $articleContent) { + $viewableArticles[$articleContent->articleID]->setArticleContent($articleContent); + } + } + } - return $articleList->getObjects(); + return $viewableArticles; } /** -- 2.20.1