From: Alexander Ebert Date: Wed, 9 Oct 2013 18:20:47 +0000 (+0200) Subject: Properly checking against excluded versions X-Git-Tag: 2.0.0_Beta_11~34^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5629f6dd14c4c742e3714d865aed372e3f437b01;p=GitHub%2FWoltLab%2FWCF.git Properly checking against excluded versions --- diff --git a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php index a22175a61c..776e61d8b5 100644 --- a/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php +++ b/wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php @@ -1,5 +1,7 @@ prepareStatement($sql); + $statement->execute(); + $excludedPackages = array(); + while ($row = $statement->fetchArray()) { + $package = $row['excludedPackage']; + $packageVersion = $row['excludedPackageVersion']; + + if (!isset($excludedPackages[$package])) { + $excludedPackages[$package] = $packageVersion; + } + else if (Package::compareVersion($excludedPackages[$package], $packageVersion) == 1) { + $excludedPackages[$package] = $packageVersion; + } + } + // filter by version $conditions = new PreparedStatementConditionBuilder(); $conditions->add("puv.packageUpdateID IN (?)", array($packageUpdateIDs)); @@ -119,6 +139,14 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction { $packageVersions = array(); while ($row = $statement->fetchArray()) { $package = $row['package']; + $packageVersion = $row['packageVersion']; + + // check excluded packages + if (isset($excludedPackages[$package]) && Package::compareVersion($excludedPackages[$package], $packageVersion) <= 0) { + // excluded, ignore + continue; + } + if (!isset($packageVersions[$package])) { $packageVersions[$package] = array(); } @@ -132,9 +160,23 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction { } if ($row['isAccessible']) { - $packageVersions[$package][$packageUpdateID]['accessible'][$row['packageUpdateVersionID']] = $row['packageVersion']; + $packageVersions[$package][$packageUpdateID]['accessible'][$row['packageUpdateVersionID']] = $packageVersion; } - $packageVersions[$package][$packageUpdateID]['existing'][$row['packageUpdateVersionID']] = $row['packageVersion']; + $packageVersions[$package][$packageUpdateID]['existing'][$row['packageUpdateVersionID']] = $packageVersion; + } + + // all found versions are excluded + if (empty($packageVersions)) { + WCF::getTPL()->assign(array( + 'packageUpdates' => array() + )); + + return array( + 'count' => 0, + 'pageCount' => 0, + 'searchID' => 0, + 'template' => WCF::getTPL()->fetch('packageSearchResultList') + ); } // determine highest versions