Improve user importer performance
authorAlexander Ebert <ebert@woltlab.com>
Thu, 12 Apr 2018 10:36:34 +0000 (12:36 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 12 Apr 2018 10:36:34 +0000 (12:36 +0200)
wcfsetup/install/files/lib/system/importer/UserImporter.class.php

index 33356c99e499d64cee24f1ea4ffafa8b47ecea69..1d1c8cdee3186d649ead0f9442e96dde2949bb9e 100644 (file)
@@ -184,12 +184,14 @@ class UserImporter extends AbstractImporter {
                                                (userID, groupID)
                        VALUES                  (?, ?)";
                $statement = WCF::getDB()->prepareStatement($sql);
+               WCF::getDB()->beginTransaction();
                foreach ($groupIDs as $groupID) {
                        $statement->execute([
                                $user->userID,
                                $groupID
                        ]);
                }
+               WCF::getDB()->commitTransaction();
                
                // save languages
                $sql = "INSERT IGNORE INTO      wcf".WCF_N."_user_to_language
@@ -208,12 +210,14 @@ class UserImporter extends AbstractImporter {
                                                (userID, eventID)
                        VALUES                  (?, ?)";
                $statement = WCF::getDB()->prepareStatement($sql);
+               WCF::getDB()->beginTransaction();
                foreach ($this->eventIDs as $eventID) {
                        $statement->execute([
                                $user->userID,
                                $eventID
                        ]);
                }
+               WCF::getDB()->commitTransaction();
                
                // save mapping
                ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user', $oldID, $user->userID);