*/
protected $contentLoading = true;
+ /**
+ * enables/disables the loading of embedded objects in the article contents
+ * @var bool
+ * @since 5.4
+ */
+ protected $embeddedObjectLoading = true;
+
/**
* @inheritDoc
*/
// get article content
if ($this->contentLoading && !empty($this->objectIDs)) {
$contentList = new ViewableArticleContentList();
+ $contentList->enableEmbeddedObjectLoading($this->embeddedObjectLoading);
$contentList->getConditionBuilder()->add('article_content.articleID IN (?)', [$this->objectIDs]);
$contentList->getConditionBuilder()->add(
'(article_content.languageID IS NULL OR article_content.languageID = ?)',
{
$this->contentLoading = $enable;
}
+
+ /**
+ * Enables/disables the loading of embedded objects in the article contents.
+ *
+ * @param bool $enable
+ * @since 5.4
+ */
+ public function enableEmbeddedObjectLoading(bool $enable = true): void
+ {
+ $this->embeddedObjectLoading = $enable;
+ }
}
*/
public $decoratorClassName = ViewableArticleContent::class;
+ /**
+ * enables/disables the loading of embedded objects in the article contents
+ * @var bool
+ * @since 5.4
+ */
+ protected $embeddedObjectLoading = true;
+
/**
* @inheritDoc
*/
}
// load embedded objects
- if (!empty($embeddedObjectContentIDs)) {
+ if ($this->embeddedObjectLoading && !empty($embeddedObjectContentIDs)) {
MessageEmbeddedObjectManager::getInstance()->loadObjects(
'com.woltlab.wcf.article.content',
$embeddedObjectContentIDs,
}
}
}
+
+ /**
+ * Enables/disables the loading of embedded objects in the article contents.
+ *
+ * @param bool $enable
+ * @since 5.4
+ */
+ public function enableEmbeddedObjectLoading(bool $enable = true): void
+ {
+ $this->embeddedObjectLoading = $enable;
+ }
}
*/
public function loadObjects(array $objectIDs)
{
- $viewableArticles = ViewableArticleRuntimeCache::getInstance()->getObjects($objectIDs);
+ // Do not use `ViewableArticleRuntimeCache` to avoid recursively loading embedded objects.
+ $articleList = new AccessibleArticleList();
+ $articleList->enableEmbeddedObjectLoading(false);
+ $articleList->getConditionBuilder()->add('article.articleID IN (?)', [$objectIDs]);
+ $articleList->readObjects();
+ $articles = $articleList->getObjects();
+
$contentLanguageID = MessageEmbeddedObjectManager::getInstance()->getContentLanguageID();
if ($contentLanguageID !== null) {
$articleIDs = [];
- foreach ($viewableArticles as $article) {
+ foreach ($articles as $article) {
if (
$article !== null
&& $article->getArticleContent()->languageID
$list->readObjects();
foreach ($list->getObjects() as $articleContent) {
- $viewableArticles[$articleContent->articleID]->setArticleContent($articleContent);
+ $articles[$articleContent->articleID]->setArticleContent($articleContent);
}
}
}
- return $viewableArticles;
+ return $articles;
}
/**