Removed unnecessary code
authorAlexander Ebert <ebert@woltlab.com>
Sun, 25 May 2014 23:43:27 +0000 (01:43 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 25 May 2014 23:43:27 +0000 (01:43 +0200)
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php

index fb35a1602cf375fd12869f70583400bb72275048..5b6d1fa41d71e5ea0702bfdc21396f723e164932 100644 (file)
@@ -112,6 +112,12 @@ class PackageUpdateDispatcher extends SingletonFactory {
                $allNewPackages = $this->parsePackageUpdateXML($reply['body']);
                unset($request, $reply);
                
+               // purge package list
+               $sql = "DELETE FROM     wcf".WCF_N."_package_update
+                       WHERE           packageUpdateServerID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($updateServer->packageUpdateServerID));
+               
                // save packages
                if (!empty($allNewPackages)) {
                        $this->savePackageUpdates($allNewPackages, $updateServer->packageUpdateServerID);
@@ -283,11 +289,6 @@ class PackageUpdateDispatcher extends SingletonFactory {
         * @param       integer         $packageUpdateServerID
         */
        protected function savePackageUpdates(array &$allNewPackages, $packageUpdateServerID) {
-               $sql = "DELETE FROM     wcf".WCF_N."_package_update
-                       WHERE           packageUpdateServerID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($packageUpdateServerID));
-               
                // insert updates
                $excludedPackagesParameters = $fromversionParameters = $insertParameters = $optionalInserts = $requirementInserts = array();
                foreach ($allNewPackages as $identifier => $packageData) {
@@ -370,19 +371,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                }
                
                // save requirements, excluded packages and fromversions
-               // use multiple inserts to save some queries
+               // insert requirements
                if (!empty($requirementInserts)) {
-                       // clear records
-                       $sql = "DELETE pur FROM wcf".WCF_N."_package_update_requirement pur
-                               LEFT JOIN       wcf".WCF_N."_package_update_version puv
-                               ON              (puv.packageUpdateVersionID = pur.packageUpdateVersionID)
-                               LEFT JOIN       wcf".WCF_N."_package_update pu
-                               ON              (pu.packageUpdateID = puv.packageUpdateID)
-                               WHERE           pu.packageUpdateServerID = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($packageUpdateServerID));
-                       
-                       // insert requirements
                        $sql = "INSERT INTO     wcf".WCF_N."_package_update_requirement
                                                (packageUpdateVersionID, package, minversion)
                                VALUES          (?, ?, ?)";
@@ -398,18 +388,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                        WCF::getDB()->commitTransaction();
                }
                
+               // insert optionals
                if (!empty($optionalInserts)) {
-                       // clear records
-                       $sql = "DELETE puo FROM wcf".WCF_N."_package_update_optional puo
-                               LEFT JOIN       wcf".WCF_N."_package_update_version puv
-                               ON              (puv.packageUpdateVersionID = puo.packageUpdateVersionID)
-                               LEFT JOIN       wcf".WCF_N."_package_update pu
-                               ON              (pu.packageUpdateID = puv.packageUpdateID)
-                               WHERE           pu.packageUpdateServerID = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($packageUpdateServerID));
-                               
-                       // insert requirements
                        $sql = "INSERT INTO     wcf".WCF_N."_package_update_optional
                                                (packageUpdateVersionID, package)
                                VALUES          (?, ?)";
@@ -424,18 +404,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                        WCF::getDB()->commitTransaction();
                }
                
+               // insert excludes
                if (!empty($excludedPackagesParameters)) {
-                       // clear records
-                       $sql = "DELETE pue FROM wcf".WCF_N."_package_update_exclusion pue
-                               LEFT JOIN       wcf".WCF_N."_package_update_version puv
-                               ON              (puv.packageUpdateVersionID = pue.packageUpdateVersionID)
-                               LEFT JOIN       wcf".WCF_N."_package_update pu
-                               ON              (pu.packageUpdateID = puv.packageUpdateID)
-                               WHERE           pu.packageUpdateServerID = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($packageUpdateServerID));
-                       
-                       // insert excludes
                        $sql = "INSERT INTO     wcf".WCF_N."_package_update_exclusion
                                                (packageUpdateVersionID, excludedPackage, excludedPackageVersion)
                                VALUES          (?, ?, ?)";
@@ -451,18 +421,8 @@ class PackageUpdateDispatcher extends SingletonFactory {
                        WCF::getDB()->commitTransaction();
                }
                
+               // insert fromversions
                if (!empty($fromversionInserts)) {
-                       // clear records
-                       $sql = "DELETE puf FROM wcf".WCF_N."_package_update_fromversion puf
-                               LEFT JOIN       wcf".WCF_N."_package_update_version puv
-                               ON              (puv.packageUpdateVersionID = puf.packageUpdateVersionID)
-                               LEFT JOIN       wcf".WCF_N."_package_update pu
-                               ON              (pu.packageUpdateID = puv.packageUpdateID)
-                               WHERE           pu.packageUpdateServerID = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($packageUpdateServerID));
-                       
-                       // insert excludes
                        $sql = "INSERT INTO     wcf".WCF_N."_package_update_fromversion
                                                (packageUpdateVersionID, fromversion)
                                VALUES          (?, ?)";