From 77082d2b86f32a124b8506e11a26f35c46021741 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 26 May 2014 01:43:27 +0200 Subject: [PATCH] Removed unnecessary code --- .../package/PackageUpdateDispatcher.class.php | 60 ++++--------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index fb35a1602c..5b6d1fa41d 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -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 (?, ?)"; -- 2.20.1