From cad980369c8b13790d5748bf042170590055977a Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 22 Aug 2016 16:34:32 +0200 Subject: [PATCH] Update ConversationMessageRebuildDataWorker --- ...ersationMessageRebuildDataWorker.class.php | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php b/files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php index 7bb1cd5..55c3ec2 100644 --- a/files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php +++ b/files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php @@ -4,6 +4,7 @@ use wcf\data\conversation\message\ConversationMessageEditor; use wcf\data\conversation\message\ConversationMessageList; use wcf\data\object\type\ObjectTypeCache; use wcf\system\exception\SystemException; +use wcf\system\html\input\HtmlInputProcessor; use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; use wcf\system\search\SearchIndexManager; use wcf\system\WCF; @@ -22,6 +23,11 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker { */ protected $limit = 500; + /** + * @var HtmlInputProcessor + */ + protected $htmlInputProcessor; + /** @noinspection PhpMissingParentCallCommonInspection */ /** * @inheritDoc @@ -89,11 +95,35 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker { $row = $attachmentStatement->fetchSingleRow(); $data['attachments'] = $row['attachments']; - // update embedded objects - throw new SystemException("TODO: we need the html input processor here"); - $data['hasEmbeddedObjects'] = (MessageEmbeddedObjectManager::getInstance()->registerObjects('com.woltlab.wcf.conversation.message') ? 1 : 0); + // update message + if (!$message->enableHtml) { + $this->getHtmlInputProcessor()->process($message->message, 'com.woltlab.wcf.conversation.message', $message->messageID, true); + $data['message'] = $this->getHtmlInputProcessor()->getHtml(); + $data['enableHtml'] = 1; + } + else { + $this->getHtmlInputProcessor()->processEmbeddedContent($message->message, 'com.woltlab.wcf.conversation.message', $message->messageID); + } + + if (MessageEmbeddedObjectManager::getInstance()->registerObjects($this->getHtmlInputProcessor())) { + $data['hasEmbeddedObjects'] = 1; + } + else { + $data['hasEmbeddedObjects'] = 0; + } $editor->update($data); } } + + /** + * @return HtmlInputProcessor + */ + protected function getHtmlInputProcessor() { + if ($this->htmlInputProcessor === null) { + $this->htmlInputProcessor = new HtmlInputProcessor(); + } + + return $this->htmlInputProcessor; + } } -- 2.20.1