Fixed attachment import issue
authorMarcel Werk <burntime@woltlab.com>
Wed, 9 Oct 2013 12:00:37 +0000 (14:00 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 9 Oct 2013 12:00:37 +0000 (14:00 +0200)
wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php

index eb7f53f5c8d763acf305dd83802f98489224d29e..c11a5e277873b0b941bd820740e8f25a9e155a5d 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\importer;
 use wcf\data\attachment\AttachmentEditor;
+use wcf\data\attachment\Attachment;
 use wcf\system\exception\SystemException;
 use wcf\util\StringUtil;
 
@@ -48,6 +49,12 @@ class AbstractAttachmentImporter extends AbstractImporter {
                // get user id
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                
+               // check existing attachment id
+               if (is_numeric($oldID)) {
+                       $attachment = new Attachment($oldID);
+                       if (!$attachment->attachmentID) $data['attachmentID'] = $oldID;
+               }
+               
                // save attachment
                $attachment = AttachmentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));