Fixed vBulletin 4.x Attachment Import: Skip unnecessary "copyFile" call

Steffen

Well-known member
Affected version
2.0.0
If the attachments are not stored in the DB but in the filesystem then a "getTempFile" and a "copyFile" call can be saved.

(Maybe rename "$attachTempFile" to "$attachSourceFile" to indicate that this file is not necessarily temporary.)

Diff:
diff --git a/xenforo/src/XF/Import/Importer/vBulletin.php b/xenforo/src/XF/Import/Importer/vBulletin.php
--- a/xenforo/src/XF/Import/Importer/vBulletin.php
+++ b/xenforo/src/XF/Import/Importer/vBulletin.php
@@ -3498,8 +3499,6 @@ class vBulletin extends AbstractForumImporter
                     continue;
                 }

-                $attachTempFile = \XF\Util\File::getTempFile();
-
                 if ($stepConfig['path'])
                 {
                     $attachFilePath = $this->getAttachmentFilePath($stepConfig['path'], $attachment);
@@ -3509,7 +3508,7 @@ class vBulletin extends AbstractForumImporter
                         continue;
                     }

-                    \XF\Util\File::copyFile($attachFilePath, $attachTempFile);
+                    $attachTempFile = $attachFilePath;
                 }
                 else
                 {
@@ -3518,6 +3517,7 @@ class vBulletin extends AbstractForumImporter
                         continue;
                     }

+                    $attachTempFile = \XF\Util\File::getTempFile();
                     \XF\Util\File::writeFile($attachTempFile, $fileData);
                 }
 
Back
Top Bottom