From: Marcel Werk Date: Tue, 6 Jul 2021 11:08:46 +0000 (+0200) Subject: Fixed missing language version for embedded articles X-Git-Tag: 5.4.0_RC_2~16 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3af7b77d40ed93c95cebb22004ab745bf69683e2;p=GitHub%2FWoltLab%2FWCF.git Fixed missing language version for embedded articles --- 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; } /**