Remove the redundant processing of attachments
authorMarcel Werk <burntime@woltlab.com>
Tue, 21 Apr 2020 13:56:00 +0000 (15:56 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 21 Apr 2020 13:56:00 +0000 (15:56 +0200)
Closes #35

14 files changed:
files/lib/system/exporter/IPB3xExporter.class.php
files/lib/system/exporter/IPB4xExporter.class.php
files/lib/system/exporter/Kunena3xExporter.class.php
files/lib/system/exporter/MyBB16xExporter.class.php
files/lib/system/exporter/PhpBB31xExporter.class.php
files/lib/system/exporter/PhpBB3xExporter.class.php
files/lib/system/exporter/SMF2xExporter.class.php
files/lib/system/exporter/VB3or4xExporter.class.php
files/lib/system/exporter/VB5xExporter.class.php
files/lib/system/exporter/WBB2xExporter.class.php
files/lib/system/exporter/WBB3xExporter.class.php
files/lib/system/exporter/WBB4xExporter.class.php
files/lib/system/exporter/XF12xExporter.class.php
files/lib/system/exporter/XoborExporter.class.php

index 879a60c5978f47ee3bc73d4d81353724088dc3fe..2913564a3c0a413ade847bad116bb85a3e220b23 100644 (file)
@@ -988,8 +988,6 @@ class IPB3xExporter extends AbstractExporter {
                                'objectID' => $row['attach_rel_id'],
                                'userID' => $row['attach_member_id'] ?: null,
                                'filename' => $row['attach_file'],
-                               'filesize' => $row['attach_filesize'],
-                               'isImage' => $row['attach_is_image'],
                                'downloads' => $row['attach_hits'],
                                'uploadTime' => $row['attach_date'],
                        ], ['fileLocation' => $fileLocation]);
index c12546fb572b3618200542fc13d83f0ec61180a1..deeab61fee31ba3255c225bdbd3ff3b8cc98ae3d 100644 (file)
@@ -977,8 +977,6 @@ class IPB4xExporter extends AbstractExporter {
                                'objectID' => $row['id2'],
                                'userID' => $row['attach_member_id'] ?: null,
                                'filename' => $row['attach_file'],
-                               'filesize' => $row['attach_filesize'],
-                               'isImage' => $row['attach_is_image'],
                                'downloads' => $row['attach_hits'],
                                'uploadTime' => $row['attach_date'],
                        ], ['fileLocation' => $fileLocation]);
index d2a6ee26fed5cdd604cd81bf3b066f92c1f09f34..0d2f4ff696b231423a8da302ba42ea518b870bdb 100644 (file)
@@ -473,16 +473,10 @@ class Kunena3xExporter extends AbstractExporter {
                while ($row = $statement->fetchArray()) {
                        $fileLocation = FileUtil::addTrailingSlash($this->fileSystemPath . $row['folder']) . $row['filename'];
                                
-                       $isImage = 0;
-                       if ($row['filetype'] == 'image/jpeg' || $row['filetype'] == 'image/png' || $row['filetype'] == 'image/gif') $isImage = 1;
-                               
                        ImportHandler::getInstance()->getImporter('com.woltlab.wbb.attachment')->import($row['id'], [
                                'objectID' => $row['mesid'],
                                'userID' => $row['userid'] ?: null,
                                'filename' => $row['filename'],
-                               'filesize' => $row['size'],
-                               'fileType' => $row['filetype'],
-                               'isImage' => $isImage
                        ], ['fileLocation' => $fileLocation]);
                }
        }
index cadd7671675c33dd99d714c01c63f6ca2602d58e..da18fd18c018f442933d549e2efb6e710898f22d 100644 (file)
@@ -833,26 +833,11 @@ class MyBB16xExporter extends AbstractExporter {
                $statement->execute([$offset + 1, $offset + $limit]);
                while ($row = $statement->fetchArray()) {
                        $fileLocation = FileUtil::addTrailingSlash($uploadsPath).$row['attachname'];
-                       if (!file_exists($fileLocation)) continue;
-                       
-                       if ($imageSize = @getimagesize($fileLocation)) {
-                               $row['isImage'] = 1;
-                               $row['width'] = $imageSize[0];
-                               $row['height'] = $imageSize[1];
-                       }
-                       else {
-                               $row['isImage'] = $row['width'] = $row['height'] = 0;
-                       }
                        
                        ImportHandler::getInstance()->getImporter('com.woltlab.wbb.attachment')->import($row['aid'], [
                                'objectID' => $row['pid'],
                                'userID' => $row['uid'] ?: null,
                                'filename' => $row['filename'],
-                               'filesize' => $row['filesize'],
-                               'fileType' => $row['filetype'],
-                               'isImage' => $row['isImage'],
-                               'width' => $row['width'],
-                               'height' => $row['height'],
                                'downloads' => $row['downloads'],
                                'uploadTime' => $row['dateuploaded']
                        ], ['fileLocation' => $fileLocation]);
index dfb9fd1bc89201ff8a41ccc380464912f1a26cf1..93f47164bcdef311f800d0eebb87d146add526c0 100644 (file)
@@ -1456,16 +1456,10 @@ class PhpBB31xExporter extends AbstractExporter {
                while ($row = $statement->fetchArray()) {
                        $fileLocation = FileUtil::addTrailingSlash($this->fileSystemPath.$upload_path).$row['physical_filename'];
                        
-                       $isImage = 0;
-                       if ($row['mimetype'] == 'image/jpeg' || $row['mimetype'] == 'image/png' || $row['mimetype'] == 'image/gif') $isImage = 1;
-                       
                        ImportHandler::getInstance()->getImporter('com.woltlab.'.($conversation ? 'wcf.conversation' : 'wbb').'.attachment')->import(0, [ // TODO: support inline attachments
                                'objectID' => $row['post_msg_id'],
                                'userID' => $row['poster_id'] ?: null,
                                'filename' => $row['real_filename'],
-                               'filesize' => $row['filesize'],
-                               'fileType' => $row['mimetype'],
-                               'isImage' => $isImage,
                                'downloads' => $row['download_count'],
                                'uploadTime' => $row['filetime']
                        ], ['fileLocation' => $fileLocation]);
index a50b2a4caebb92f2faf0fd6da9f4389d23599b0c..ee2afe6c0c3f0d27af94c758c195e219a7ae608c 100644 (file)
@@ -1389,16 +1389,10 @@ class PhpBB3xExporter extends AbstractExporter {
                while ($row = $statement->fetchArray()) {
                        $fileLocation = FileUtil::addTrailingSlash($this->fileSystemPath.$upload_path).$row['physical_filename'];
                        
-                       $isImage = 0;
-                       if ($row['mimetype'] == 'image/jpeg' || $row['mimetype'] == 'image/png' || $row['mimetype'] == 'image/gif') $isImage = 1;
-                       
                        ImportHandler::getInstance()->getImporter('com.woltlab.'.($conversation ? 'wcf.conversation' : 'wbb').'.attachment')->import(0, [ // TODO: support inline attachments
                                'objectID' => $row['post_msg_id'],
                                'userID' => $row['poster_id'] ?: null,
                                'filename' => $row['real_filename'],
-                               'filesize' => $row['filesize'],
-                               'fileType' => $row['mimetype'],
-                               'isImage' => $isImage,
                                'downloads' => $row['download_count'],
                                'uploadTime' => $row['filetime']
                        ], ['fileLocation' => $fileLocation]);
index 24980059bc9616dcc9ee9fd7c8a6e1f27086a863..33e827e603fc19025c16e007f66afe2fea403261 100644 (file)
@@ -948,24 +948,10 @@ class SMF2xExporter extends AbstractExporter {
                        
                        $fileLocation = $this->getAttachmentFilename($row['id_attach'], $row['id_folder'], $row['file_hash'], $row['filename']);
                        
-                       if ($imageSize = @getimagesize($fileLocation)) {
-                               $row['isImage'] = 1;
-                               $row['width'] = $imageSize[0];
-                               $row['height'] = $imageSize[1];
-                       }
-                       else {
-                               $row['isImage'] = $row['width'] = $row['height'] = 0;
-                       }
-                       
                        ImportHandler::getInstance()->getImporter('com.woltlab.wbb.attachment')->import($row['id_attach'], [
                                'objectID' => $row['id_msg'],
                                'userID' => $row['id_member'] ?: null,
                                'filename' => $row['filename'],
-                               'filesize' => $row['size'],
-                               'fileType' => $row['mime_type'],
-                               'isImage' => $row['isImage'],
-                               'width' => $row['width'],
-                               'height' => $row['height'],
                                'downloads' => $row['downloads'],
                                'uploadTime' => $row['poster_time']
                        ], ['fileLocation' => $fileLocation]);
index 6fe70c8b5b3a1d44a22273e2a870a90defc49396..7d2b553eed78ba9ba623aa1501cc34c89880b65e 100644 (file)
@@ -2064,24 +2064,11 @@ class VB3or4xExporter extends AbstractExporter {
                                
                                // unable to read file -> abort
                                if (!is_file($file) || !is_readable($file)) continue;
-                               if ($imageSize = @getimagesize($file)) {
-                                       $row['isImage'] = 1;
-                                       $row['width'] = $imageSize[0];
-                                       $row['height'] = $imageSize[1];
-                               }
-                               else {
-                                       $row['isImage'] = $row['width'] = $row['height'] = 0;
-                               }
                                
                                ImportHandler::getInstance()->getImporter($importer)->import($row['attachmentid'], [
                                        'objectID' => $row['contentid'],
                                        'userID' => $row['userid'] ?: null,
                                        'filename' => $row['filename'],
-                                       'filesize' => isset($row['filesize']) ? $row['filesize'] : filesize($file),
-                                       'fileType' => FileUtil::getMimeType($file),
-                                       'isImage' => $row['isImage'],
-                                       'width' => $row['width'],
-                                       'height' => $row['height'],
                                        'downloads' => $row['counter'],
                                        'uploadTime' => $row['dateline'],
                                        'showOrder' => isset($row['displayOrder']) ? $row['displayOrder'] : 0
index f256f29adf0245fe2c0d396cc297d1f9124c5bb5..f0dd83503f9408b6bc4109dc67a31a57c67ca830 100644 (file)
@@ -594,24 +594,11 @@ class VB5xExporter extends AbstractExporter {
                                
                                // unable to read file -> abort
                                if (!is_file($file) || !is_readable($file)) continue;
-                               if ($imageSize = @getimagesize($file)) {
-                                       $row['isImage'] = 1;
-                                       $row['width'] = $imageSize[0];
-                                       $row['height'] = $imageSize[1];
-                               }
-                               else {
-                                       $row['isImage'] = $row['width'] = $row['height'] = 0;
-                               }
                                
                                ImportHandler::getInstance()->getImporter('com.woltlab.wbb.attachment')->import($row['nodeid'], [
                                        'objectID' => $row['parentid'],
                                        'userID' => $row['userid'] ?: null,
                                        'filename' => $row['filename'],
-                                       'filesize' => isset($row['filesize']) ? $row['filesize'] : filesize($file),
-                                       'fileType' => FileUtil::getMimeType($file),
-                                       'isImage' => $row['isImage'],
-                                       'width' => $row['width'],
-                                       'height' => $row['height'],
                                        'downloads' => $row['counter'],
                                        'uploadTime' => $row['dateline'],
                                        'showOrder' => isset($row['displayOrder']) ? $row['displayOrder'] : 0
index 2e96dd5a375645fc925cecbb80c75e0047d8e458..06322471aee9e71b71d96b41f46c96944b1abebf 100644 (file)
@@ -1142,19 +1142,11 @@ class WBB2xExporter extends AbstractExporter {
                $statement->execute([0]);
                while ($row = $statement->fetchArray()) {
                        $fileLocation = $this->fileSystemPath.'attachments/attachment-'.$row['attachmentid'].'.'.$row['attachmentextension'];
-                       if (!@file_exists($fileLocation)) continue;
-                       
-                       $fileType = FileUtil::getMimeType($fileLocation);
-                       $isImage = 0;
-                       if ($fileType == 'image/jpeg' || $fileType == 'image/png' || $fileType == 'image/gif') $isImage = 1;
                        
                        ImportHandler::getInstance()->getImporter($objectType)->import($row['attachmentid'], [
                                'objectID' => $row[$indexName],
                                'userID' => (!empty($row['userid']) ? $row['userid'] : null),
                                'filename' => $row['attachmentname'].'.'.$row['attachmentextension'],
-                               'filesize' => $row['attachmentsize'],
-                               'fileType' => $fileType,
-                               'isImage' => $isImage,
                                'downloads' => $row['counter'],
                                'uploadTime' => (!empty($row['uploadtime']) ? $row['uploadtime'] : 0),
                                'showOrder' => 0
index b36321a442f910704dccc1adb1c895c3faaa82b0..03d7ec96c5333f4f37856a9f70f262003de48fc1 100644 (file)
@@ -2431,9 +2431,6 @@ class WBB3xExporter extends AbstractExporter {
                                'objectID' => $row['eventID'],
                                'userID' => $row['userID'] ?: null,
                                'filename' => $row['attachmentName'],
-                               'filesize' => $row['attachmentSize'],
-                               'fileType' => $row['fileType'],
-                               'isImage' => $row['isImage'],
                                'downloads' => $row['downloads'],
                                'lastDownloadTime' => $row['lastDownloadTime'],
                                'uploadTime' => $row['uploadTime'],
@@ -2629,9 +2626,6 @@ class WBB3xExporter extends AbstractExporter {
                                'objectID' => !empty($row['containerID']) ? $row['containerID'] : $row['messageID'],
                                'userID' => $row['userID'] ?: null,
                                'filename' => $row['attachmentName'],
-                               'filesize' => $row['attachmentSize'],
-                               'fileType' => $row['fileType'],
-                               'isImage' => $row['isImage'],
                                'downloads' => $row['downloads'],
                                'lastDownloadTime' => $row['lastDownloadTime'],
                                'uploadTime' => $row['uploadTime'],
index c868e713baeac6c4fef25c5ddb6ffdd3005294f3..44aaebde89707062852ee9d4c6ea95631ba1fffb 100644 (file)
@@ -3089,12 +3089,6 @@ class WBB4xExporter extends AbstractExporter {
                                'objectID' => $row['objectID'],
                                'userID' => $row['userID'] ?: null,
                                'filename' => $row['filename'],
-                               'filesize' => $row['filesize'],
-                               'fileType' => $row['fileType'],
-                               'fileHash' => $row['fileHash'],
-                               'isImage' => $row['isImage'],
-                               'width' => $row['width'],
-                               'height' => $row['height'],
                                'downloads' => $row['downloads'],
                                'lastDownloadTime' => $row['lastDownloadTime'],
                                'uploadTime' => $row['uploadTime'],
index 602d8facf5fcd7d80bc8da33f0750ccf653bb4fb..4f0981db0eebcde65129e1e017b7eeef6fa8ac32 100644 (file)
@@ -1417,26 +1417,10 @@ class XF12xExporter extends AbstractExporter {
                        $config = self::getConfig();
                        $fileLocation = $this->fileSystemPath.$config['internalDataPath'].'/attachments/'.floor($row['data_id'] / 1000).'/'.$row['data_id'].'-'.$row['file_hash'].'.data';
                        
-                       if (!file_exists($fileLocation)) continue;
-                       
-                       if ($imageSize = @getimagesize($fileLocation)) {
-                               $row['isImage'] = 1;
-                               $row['width'] = $imageSize[0];
-                               $row['height'] = $imageSize[1];
-                       }
-                       else {
-                               $row['isImage'] = $row['width'] = $row['height'] = 0;
-                       }
-                       
                        ImportHandler::getInstance()->getImporter($objectType)->import($row['attachment_id'], [
                                'objectID' => $row['content_id'],
                                'userID' => $row['user_id'] ?: null,
                                'filename' => $row['filename'],
-                               'filesize' => $row['file_size'],
-                               'fileType' => FileUtil::getMimeType($fileLocation) ?: 'application/octet-stream',
-                               'isImage' => $row['isImage'],
-                               'width' => $row['width'],
-                               'height' => $row['height'],
                                'downloads' => $row['view_count'],
                                'uploadTime' => $row['upload_date']
                        ], ['fileLocation' => $fileLocation]);
index 844208e8d0a2ab0f519e2c79f9f68d55f5256ad2..f6af2cfe6d2a7ef39435cc6d76bb0c72a8efc62b 100644 (file)
@@ -320,16 +320,6 @@ class XoborExporter extends AbstractExporter {
                        foreach ($files as $file) {
                                if (!isset($file['filelink'])) continue;
                                $fileLocation = FileUtil::addTrailingSlash($this->fileSystemPath).$file['filelink'];
-                               if (!file_exists($fileLocation)) continue;
-                               
-                               if ($imageSize = @getimagesize($fileLocation)) {
-                                       $row['isImage'] = 1;
-                                       $row['width'] = $imageSize[0];
-                                       $row['height'] = $imageSize[1];
-                               }
-                               else {
-                                       $row['isImage'] = $row['width'] = $row['height'] = 0;
-                               }
                                
                                $filename = $file['filename'] ?? $row['filelink'];
                                if ($convert) $filename = mb_convert_encoding($filename, 'UTF-8', 'ISO-8859-1');
@@ -337,11 +327,6 @@ class XoborExporter extends AbstractExporter {
                                        'objectID' => $row['id'],
                                        'userID' => $row['userid'] ?: null,
                                        'filename' => $filename,
-                                       'filesize' => filesize($fileLocation),
-                                       'fileType' => FileUtil::getMimeType($fileLocation),
-                                       'isImage' => $row['isImage'],
-                                       'width' => $row['width'],
-                                       'height' => $row['height'],
                                        'downloads' => 0,
                                        'uploadTime' => strtotime($row['writetime'])
                                ], ['fileLocation' => $fileLocation]);