Importer optimizations
authorMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:34:49 +0000 (21:34 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:34:49 +0000 (21:34 +0200)
16 files changed:
wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractCommentImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractCommentResponseImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractLikeImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractPollImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractPollOptionImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractPollOptionVoteImporter.class.php
wcfsetup/install/files/lib/system/importer/AbstractWatchedObjectImporter.class.php
wcfsetup/install/files/lib/system/importer/IImporter.class.php
wcfsetup/install/files/lib/system/importer/UserAvatarImporter.class.php
wcfsetup/install/files/lib/system/importer/UserCommentImporter.class.php
wcfsetup/install/files/lib/system/importer/UserFollowerImporter.class.php
wcfsetup/install/files/lib/system/importer/UserGroupImporter.class.php
wcfsetup/install/files/lib/system/importer/UserImporter.class.php
wcfsetup/install/files/lib/system/importer/UserOptionImporter.class.php
wcfsetup/install/files/lib/system/importer/UserRankImporter.class.php

index 726c2abc8eda06ce8345a7863ed98468b2ae1c64..2ae24f7e929ef9e0fa3aeb95d800615969b2b209 100644 (file)
@@ -25,15 +25,12 @@ class AbstractAttachmentImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
-               $fileLocation = $data['fileLocation'];
-               unset($data['fileLocation']);
-               
+       public function import($oldID, array $data, array $additionalData = array()) {
                // check file location
-               if (!@file_exists($fileLocation)) return 0;
+               if (!@file_exists($additionalData['fileLocation'])) return 0;
                
                // get file hash
-               if (empty($data['fileHash'])) $data['fileHash'] = sha1_file($fileLocation);
+               if (empty($data['fileHash'])) $data['fileHash'] = sha1_file($additionalData['fileLocation']);
                
                // get user id
                if ($data['userID']) $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
@@ -54,7 +51,7 @@ class AbstractAttachmentImporter implements IImporter {
                
                // copy file
                try {
-                       if (!copy($fileLocation, $attachment->getLocation())) {
+                       if (!copy($additionalData['fileLocation'], $attachment->getLocation())) {
                                throw new SystemException();
                        }
                                
index 607ece88da5aa5bdba1c59fb00a9640b26063cc5..d58786ed65d644bc5895a7e153315b962fb004c9 100644 (file)
@@ -28,7 +28,7 @@ class AbstractCommentImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                if ($data['userID']) $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                
                $action = new CommentAction(array(), 'create', array(
index b0047e470fab6d79a3c8c187262354358bb3519e..7d46815adcbe2a5ee75b890a96a11b3ade857f59 100644 (file)
@@ -22,7 +22,7 @@ class AbstractCommentResponseImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                if ($data['userID']) $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                
                $data['commentID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['commentID']);
index 14d24c58a58079e1f20db84979246687f764e7c6..46adfe34a9e76fcfe9856120b04109500d20c093 100644 (file)
@@ -22,7 +22,7 @@ class AbstractLikeImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                if ($data['objectUserID']) $data['objectUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectUserID']);
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
                if (!$data['userID']) return 0;
index 31cf2fabedb9fea577b218221c96011a1d25d4b6..e92bf9f289fb0a935960d1d18bad84856b5bed34 100644 (file)
@@ -28,7 +28,7 @@ class AbstractPollImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $poll = PollEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
                
                ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $poll->pollID);
index 8f1d8693c859db85d7c7600261d68bdbb4bc4585..6857b73fe4cd5d924b87fd77614f18276db4b54b 100644 (file)
@@ -28,7 +28,7 @@ class AbstractPollOptionImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
                if (!$data['pollID']) return 0;
                
index 1610dedb855ab29bc607e7ed73699b256997af1a..c01c3353f43c5e35e8be0f5dd5793e729988fb8c 100644 (file)
@@ -28,7 +28,7 @@ class AbstractPollOptionVoteImporter 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 1329628ef1ac7c6145594b95b448b70a53f6811f..18b4a33ff8636dd68dc824a935ebab9b8aa999ef 100644 (file)
@@ -22,7 +22,7 @@ class AbstractWatchedObjectImporter 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 a7a1d2a4230d38464efba1ff0e32e3606dc2f2e0..a6a2590122af78edc91edf50e2bec55bef8b0342 100644 (file)
@@ -17,7 +17,8 @@ interface IImporter {
         * 
         * @param       mixed           $oldID
         * @param       array           $data
+        * @param       array           $additionalData
         * @return      mixed           new id
         */
-       public function import($oldID, array $data);
+       public function import($oldID, array $data, array $additionalData = array());
 }
index 669cb7eaf5c85fe54bf6955c89845a011f45040c..9906218b9a3f6fb06bd9dfc81b8936f956f0e535 100644 (file)
@@ -20,15 +20,12 @@ class UserAvatarImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
-               $fileLocation = $data['fileLocation'];
-               unset($data['fileLocation']);
-               
+       public function import($oldID, array $data, array $additionalData = array()) {
                // check file location
-               if (!@file_exists($fileLocation)) return 0;
+               if (!@file_exists($additionalData['fileLocation'])) return 0;
                
                // get image size
-               $imageData = @getimagesize($fileLocation);
+               $imageData = @getimagesize($additionalData['fileLocation']);
                if ($imageData === false) return 0;
                $data['width'] = $imageData[0];
                $data['height'] = $imageData[1];
@@ -39,7 +36,7 @@ class UserAvatarImporter implements IImporter {
                if ($imageData[2] != IMAGETYPE_GIF && $imageData[2] != IMAGETYPE_JPEG && $imageData[2] != IMAGETYPE_PNG) return 0;
                
                // get file hash
-               if (empty($data['fileHash'])) $data['fileHash'] = sha1_file($fileLocation);
+               if (empty($data['fileHash'])) $data['fileHash'] = sha1_file($additionalData['fileLocation']);
                
                // get user id
                $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
@@ -61,7 +58,7 @@ class UserAvatarImporter implements IImporter {
                
                // copy file
                try {
-                       if (!copy($fileLocation, $avatar->getLocation())) {
+                       if (!copy($additionalData['fileLocation'], $avatar->getLocation())) {
                                throw new SystemException();
                        }
                        
index 0ed7fbac342416d7c7b7d12da66382f6c50b4bcf..5b9448950d4ece6e22211a9ed445d6cc9a4b57d1 100644 (file)
@@ -30,7 +30,7 @@ class UserCommentImporter extends AbstractCommentImporter {
        /**
         * @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.user', $data['objectID']);
                if (!$data['objectID']) return 0;
                
index c2cf18becb17baac5fe64dac1cf8d1bada8ddf41..f357d209ac332d0f96f17852e900d80885ff2074 100644 (file)
@@ -16,7 +16,7 @@ class UserFollowerImporter 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']);
                $data['followUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['followUserID']);
                if (!$data['userID'] || !$data['followUserID']) return 0;
index 96d8222e1006e75d58e34290d4b8ddc62687de1b..46b72280691e8802fa5de90415edf24d1072e625 100644 (file)
@@ -16,7 +16,7 @@ class UserGroupImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $action = new UserGroupAction(array(), 'create', array(
                        'data' => $data         
                ));
index 0a5fe99a0d701fdbe3edf3c11bbd4c84ddb3b852..5bc39b6eb3735db761c4bedcd8afc503c6b1c7b8 100644 (file)
@@ -19,7 +19,7 @@ class UserImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                // check existing user id
                $sql = "SELECT  COUNT(*) AS count
                        FROM    wcf".WCF_N."_user
@@ -31,19 +31,17 @@ class UserImporter implements IImporter {
                
                // get group ids
                $groupIDs = array();
-               if (isset($data['groupIDs'])) {
-                       foreach ($data['groupIDs'] as $oldGroupID) {
+               if (isset($additionalData['groupIDs'])) {
+                       foreach ($additionalData['groupIDs'] as $oldGroupID) {
                                $newGroupID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $oldGroupID);
                                if ($newGroupID) $groupIDs[] = $newGroupID;
                        }
-                       
-                       unset($data['groupIDs']);
                }
                
                // handle user options
                $userOptions = array();
-               if (isset($data['options'])) {
-                       foreach ($data['options'] as $optionName => $optionValue) {
+               if (isset($additionalData['options'])) {
+                       foreach ($additionalData['options'] as $optionName => $optionValue) {
                                if (is_int($optionName)) $optionID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.option', $optionName);
                                else $optionID = User::getUserOptionID($optionName);
                                
@@ -51,8 +49,6 @@ class UserImporter implements IImporter {
                                        $userOptions[$optionID] = $optionValue;
                                }
                        }
-                       
-                       unset($data['options']);
                }
                
                // create user
index adcdfce13ef016763c69e618c1714926ecd90cf0..1a3b50c3a457e0bd28081fded862c8ddc8faf077 100644 (file)
@@ -39,9 +39,7 @@ class UserOptionImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
-               $name = $data['name'];
-               unset($data['name']);
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['packageID'] = 1;
                
                // save option
@@ -63,7 +61,7 @@ class UserOptionImporter implements IImporter {
                $statement->execute(array(
                        LanguageFactory::getInstance()->getDefaultLanguageID(),
                        'wcf.user.option.option'.$userOption->optionID,
-                       $name,
+                       $additionalData,
                        0,
                        $this->languageCategoryID,
                        1
index a79100b07486f77686c47df14113e6c1b1acf3f5..49d487aacf5b6b96a88fe92a31ebafa5eed30fff 100644 (file)
@@ -17,7 +17,7 @@ class UserRankImporter implements IImporter {
        /**
         * @see wcf\system\importer\IImporter::import()
         */
-       public function import($oldID, array $data) {
+       public function import($oldID, array $data, array $additionalData = array()) {
                $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']);
                if (!$data['groupID']) $data['groupID'] = UserGroup::getGroupByType(UserGroup::USERS)->groupID;