Update `hasEmbeddedObjects` in comment (response) rebuild data worker
authorMatthias Schmidt <gravatronics@live.com>
Wed, 9 Jun 2021 13:09:31 +0000 (15:09 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 9 Jun 2021 13:09:31 +0000 (15:09 +0200)
wcfsetup/install/files/lib/system/worker/CommentRebuildDataWorker.class.php
wcfsetup/install/files/lib/system/worker/CommentResponseRebuildDataWorker.class.php

index d8a23beceda856edc5cd40d5d3c38793d4740658..21c345c23211f0fed413c12a8dcd8a11c126b943 100644 (file)
@@ -7,6 +7,7 @@ use wcf\data\comment\CommentEditor;
 use wcf\data\comment\CommentList;
 use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\WCF;
 
 /**
@@ -92,6 +93,8 @@ class CommentRebuildDataWorker extends AbstractRebuildDataWorker
                 $this->getBulkUserPermissionValue($userPermissions, $comment->userID, 'user.comment.disallowedBBCodes')
             ));
 
+            $data = [];
+
             // update message
             if (!$comment->enableHtml) {
                 $this->getHtmlInputProcessor()->process(
@@ -101,18 +104,23 @@ class CommentRebuildDataWorker extends AbstractRebuildDataWorker
                     true
                 );
 
-                $commentEditor->update([
-                    'message' => $this->getHtmlInputProcessor()->getHtml(),
-                    'enableHtml' => 1,
-                ]);
+                $data['enableHtml'] = 1;
             } else {
                 $this->getHtmlInputProcessor()->reprocess(
                     $comment->message,
                     'com.woltlab.wcf.comment',
                     $comment->commentID
                 );
-                $commentEditor->update(['message' => $this->getHtmlInputProcessor()->getHtml()]);
             }
+
+            if (MessageEmbeddedObjectManager::getInstance()->registerObjects($this->getHtmlInputProcessor(), true)) {
+                $data['hasEmbeddedObjects'] = 1;
+            } else {
+                $data['hasEmbeddedObjects'] = 0;
+            }
+
+            $data['message'] = $this->getHtmlInputProcessor()->getHtml();
+            $commentEditor->update($data);
         }
         WCF::getDB()->commitTransaction();
     }
index 6cb4e68f7e2182788a48b5ac26d7cea542739c4b..1a34ffe5fb9defd7dafc03b78c88cc796e199580 100644 (file)
@@ -7,6 +7,7 @@ use wcf\data\comment\response\CommentResponseEditor;
 use wcf\data\comment\response\CommentResponseList;
 use wcf\system\bbcode\BBCodeHandler;
 use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\WCF;
 
 /**
@@ -89,6 +90,8 @@ class CommentResponseRebuildDataWorker extends AbstractRebuildDataWorker
                 $this->getBulkUserPermissionValue($userPermissions, $response->userID, 'user.comment.disallowedBBCodes')
             ));
 
+            $data = [];
+
             // update message
             if (!$response->enableHtml) {
                 $this->getHtmlInputProcessor()->process(
@@ -98,18 +101,23 @@ class CommentResponseRebuildDataWorker extends AbstractRebuildDataWorker
                     true
                 );
 
-                $responseEditor->update([
-                    'message' => $this->getHtmlInputProcessor()->getHtml(),
-                    'enableHtml' => 1,
-                ]);
+                $data['enableHtml'] = 1;
             } else {
                 $this->getHtmlInputProcessor()->reprocess(
                     $response->message,
                     'com.woltlab.wcf.comment.response',
                     $response->responseID
                 );
-                $responseEditor->update(['message' => $this->getHtmlInputProcessor()->getHtml()]);
             }
+
+            if (MessageEmbeddedObjectManager::getInstance()->registerObjects($this->getHtmlInputProcessor(), true)) {
+                $data['hasEmbeddedObjects'] = 1;
+            } else {
+                $data['hasEmbeddedObjects'] = 0;
+            }
+
+            $data['message'] = $this->getHtmlInputProcessor()->getHtml();
+            $responseEditor->update($data);
         }
         WCF::getDB()->commitTransaction();
     }