$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);
* @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) {
}
// 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 (?, ?, ?)";
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 (?, ?)";
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 (?, ?, ?)";
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 (?, ?)";