Merge branch '3.1' into 5.2
authorMarcel Werk <burntime@woltlab.com>
Tue, 23 Jun 2020 15:38:51 +0000 (17:38 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 23 Jun 2020 15:38:51 +0000 (17:38 +0200)
1  2 
wcfsetup/install/files/lib/data/article/content/ViewableArticleContentList.class.php
wcfsetup/install/files/lib/data/media/ViewableMediaList.class.php

index a4600f811fb0078efee8834e4e0911e13320eb88,c2cef7ea8aa9ec66761efb4ea30f3d431c9a2b57..f859f9217624b8c41a01cb69901ac7d789b2688b
@@@ -41,36 -40,21 +41,38 @@@ class ViewableArticleContentList extend
                        if ($articleContent->hasEmbeddedObjects) {
                                $embeddedObjectPostIDs[] = $articleContent->articleContentID;
                        }
 +                      
 +                      $articleIDs[] = $articleContent->articleID;
                }
                
+               $contentLanguageID = null;
+               if (count($this->objects) === 1) {
+                       $contentLanguageID = reset($this->objects)->languageID;
+               }
+               
                // cache images
                if (!empty($imageIDs)) {
-                       $mediaList = new ViewableMediaList();
+                       $mediaList = new ViewableMediaList($contentLanguageID);
                        $mediaList->setObjectIDs($imageIDs);
                        $mediaList->readObjects();
                        $images = $mediaList->getObjects();
 -                      
 -                      foreach ($this->getObjects() as $articleContent) {
 +              }
 +              
 +              // load embedded objects
 +              if (!empty($embeddedObjectPostIDs)) {
-                       $contentLanguageID = null;
-                       if (count($embeddedObjectPostIDs) === 1) $contentLanguageID = reset($this->objects)->languageID;
-                       
 +                      MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.article.content', $embeddedObjectPostIDs, $contentLanguageID);
 +              }
 +              
 +              if (!empty($articleIDs)) {
 +                      $articleList = new ViewableArticleList();
 +                      // to prevent an infinity loop, because the list loads otherwise the article content
 +                      $articleList->enableContentLoading(false);
 +                      $articleList->setObjectIDs($articleIDs);
 +                      $articleList->readObjects();
 +              }
 +              
 +              foreach ($this->getObjects() as $articleContent) {
 +                      if (isset($images)) {
                                if ($articleContent->imageID && isset($images[$articleContent->imageID])) {
                                        $articleContent->setImage($images[$articleContent->imageID]);
                                }