Added missing update of embedded objects
authorMarcel Werk <burntime@woltlab.com>
Sat, 8 Oct 2016 21:23:51 +0000 (23:23 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 8 Oct 2016 21:23:51 +0000 (23:23 +0200)
wcfsetup/install/files/lib/system/worker/ArticleRebuildDataWorker.class.php

index a8e4891f5a7f53714061f8efc8dc7ecc96c8cfef..bd0e110b1efa46f499a0203ed9cd8257ae4ff2e7 100644 (file)
@@ -1,10 +1,13 @@
 <?php
 namespace wcf\system\worker;
+use wcf\data\article\content\ArticleContentEditor;
 use wcf\data\article\content\ArticleContentList;
 use wcf\data\article\ArticleEditor;
 use wcf\data\article\ArticleList;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\search\SearchIndexManager;
 use wcf\system\WCF;
 
@@ -30,6 +33,11 @@ class ArticleRebuildDataWorker extends AbstractRebuildDataWorker {
         */
        protected $limit = 100;
        
+       /**
+        * @var HtmlInputProcessor
+        */
+       protected $htmlInputProcessor;
+       
        /**
         * @inheritDoc
         */
@@ -86,6 +94,19 @@ class ArticleRebuildDataWorker extends AbstractRebuildDataWorker {
                                $articleContent->languageID,
                                $articleContent->teaser
                        );
+                       
+                       // update embedded objects
+                       $this->getHtmlInputProcessor()->processEmbeddedContent($articleContent->content, 'com.woltlab.wcf.article.content', $articleContent->articleContentID);
+                       
+                       $hasEmbeddedObjects = 0;
+                       if (MessageEmbeddedObjectManager::getInstance()->registerObjects($this->getHtmlInputProcessor())) {
+                               $hasEmbeddedObjects = 1;
+                       }
+                       
+                       if ($hasEmbeddedObjects != $articleContent->hasEmbeddedObjects) {
+                               $articleContentEditor = new ArticleContentEditor($articleContent);
+                               $articleContentEditor->update(['hasEmbeddedObjects' => $hasEmbeddedObjects]);
+                       }
                }
                
                // fetch cumulative likes
@@ -114,4 +135,15 @@ class ArticleRebuildDataWorker extends AbstractRebuildDataWorker {
                        $editor->update($data);
                }
        }
+       
+       /**
+        * @return HtmlInputProcessor
+        */
+       protected function getHtmlInputProcessor() {
+               if ($this->htmlInputProcessor === null) {
+                       $this->htmlInputProcessor = new HtmlInputProcessor();
+               }
+               
+               return $this->htmlInputProcessor;
+       }
 }