Importer optimizations
authorMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:36:07 +0000 (21:36 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:36:07 +0000 (21:36 +0200)
files/lib/system/importer/ConversationAttachmentImporter.class.php
files/lib/system/importer/ConversationImporter.class.php
files/lib/system/importer/ConversationLabelImporter.class.php
files/lib/system/importer/ConversationMessageImporter.class.php
files/lib/system/importer/ConversationUserImporter.class.php

index b6cb3966ab1e4c88b68c72aacf55908e8ef85ee1..39784040f4317702b38f2b08166cc7feb56618ff 100644 (file)
@@ -27,20 +27,17 @@ class ConversationAttachmentImporter extends AbstractAttachmentImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['objectID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation.message', $data['objectID']);
                if (!$data['objectID']) return 0;
                
                $attachmentID = parent::import($oldID, $data);
                if ($attachmentID && $attachmentID != $oldID) {
                        // fix embedded attachments
-                       $message = new ConversationMessage($data['objectID']);
+                       $messageObj = new ConversationMessage($data['objectID']);
                        
-                       if (StringUtil::indexOfIgnoreCase($message->message, '[attach]'.$oldID.'[/attach]') !== false || StringUtil::indexOfIgnoreCase($message->message, '[attach='.$oldID.']') !== false) {
-                               $newMessage = StringUtil::replaceIgnoreCase('[attach]'.$oldID.'[/attach]', '[attach]'.$attachmentID.'[/attach]', $message->message);
-                               $newMessage = StringUtil::replaceIgnoreCase('[attach='.$oldID.']', '[attach='.$attachmentID.']', $newMessage);
-                               
-                               $editor = new ConversationMessageEditor($message);
+                       if (($newMessage = $this->fixEmbeddedAttachments($messageObj->message, $oldID, $attachmentID)) !== false) {
+                               $editor = new ConversationMessageEditor($messageObj);
                                $editor->update(array(
                                        'message' => $newMessage        
                                ));
index d448d72dfaea4a13f688361c79a0a01d5b3613c7..64ec98e5b3da9313de176c5e4ab8b7b18c2c5a75 100644 (file)
@@ -17,7 +17,7 @@ class ConversationImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                
                // check existing conversation
index 7bc8c994f17d8805d77bad00ed190e20b8791136..d8a91e6cc91b50140bfa3256700592d2e08bf0c0 100644 (file)
@@ -16,7 +16,7 @@ class ConversationLabelImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                if (!$data['userID']) return 0;
                
index 48a3c46047119c3d45414a7380def48f508057c4..dc5f977b4d446363fd2a26612cdfc928c4b8287b 100644 (file)
@@ -17,7 +17,7 @@ class ConversationMessageImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['conversationID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation', $data['conversationID']);
                if (!$data['conversationID']) return 0;
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
index 72cf72c64c3333afcb62a053491c01fa841257de..eaeab5a4aef8146050e0e6f209f9b9c93b797782 100644 (file)
@@ -18,7 +18,7 @@ class ConversationUserImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['conversationID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation', $data['conversationID']);
                if (!$data['conversationID']) return 0;
                $data['participantID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['participantID']);
@@ -36,12 +36,12 @@ class ConversationUserImporter implements IImporter {
                ));
                
                // save labels
-               if ($data['participantID'] && !empty($data['labelIDs'])) {
+               if ($data['participantID'] && !empty($additionalData['labelIDs'])) {
                        $sql = "INSERT IGNORE INTO              wcf".WCF_N."_conversation_label_to_object
                                                                (labelID, conversationID)
                                VALUES                          (?, ?)";
                        $statement = WCF::getDB()->prepareStatement($sql);
-                       foreach ($data['labelIDs'] as $labelID) {
+                       foreach ($additionalData['labelIDs'] as $labelID) {
                                $labelID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation.label', $labelID);
                                if ($labelID) $statement->execute(array($labelID, $data['conversationID']));
                        }