Added missing exclusion checks of installed packages
authorMarcel Werk <burntime@woltlab.com>
Fri, 22 Jul 2016 17:27:59 +0000 (19:27 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 22 Jul 2016 17:27:59 +0000 (19:27 +0200)
wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php

index c70b8952c527b17e48b581f4442726b9af274b2d..7e645ae62d238d44a6fca4a014463462d763a011 100644 (file)
@@ -127,10 +127,13 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                }
                
                // get excluded packages
+               $conditions = new PreparedStatementConditionBuilder();
+               $conditions->add("packageUpdateVersionID IN (SELECT packageUpdateVersionID FROM wcf".WCF_N."_package_update_version WHERE packageUpdateID IN (?))", [$packageUpdateIDs]);
                $sql = "SELECT  *
-                       FROM    wcf".WCF_N."_package_update_exclusion";
+                       FROM    wcf".WCF_N."_package_update_exclusion
+                       ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute();
+               $statement->execute($conditions->getParameters());
                $excludedPackages = [];
                while ($row = $statement->fetchArray()) {
                        $package = $row['excludedPackage'];
@@ -152,6 +155,21 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                $statement->execute();
                $installedPackages = $statement->fetchMap('package', 'packageVersion');
                
+               // get excluded packages (of installed packages)
+               $excludedPackagesOfInstalledPackages = [];
+               $sql = "SELECT  excludedPackage, excludedPackageVersion
+                       FROM    wcf".WCF_N."_package_exclusion";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute();
+               while ($row = $statement->fetchArray()) {
+                       if (!isset($excludedPackagesOfInstalledPackages[$row['excludedPackage']])) {
+                               $excludedPackagesOfInstalledPackages[$row['excludedPackage']] = $row['excludedPackageVersion'];
+                       }
+                       else if (Package::compareVersion($excludedPackagesOfInstalledPackages[$row['excludedPackage']], $row['excludedPackageVersion'], '>')) {
+                               $excludedPackagesOfInstalledPackages[$row['excludedPackage']] = $row['excludedPackageVersion'];
+                       }
+               }
+               
                // filter by version
                $conditions = new PreparedStatementConditionBuilder();
                $conditions->add("puv.packageUpdateID IN (?)", [$packageUpdateIDs]);
@@ -183,6 +201,12 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                                        continue;
                                }
                        }
+                       // check excluded packages of installed packages
+                       if (isset($excludedPackagesOfInstalledPackages[$row['package']])) {
+                               if (Package::compareVersion($packageVersion, $excludedPackagesOfInstalledPackages[$row['package']], '>=')) {
+                                       continue;
+                               }
+                       }
                        
                        if (!isset($packageVersions[$package])) {
                                $packageVersions[$package] = [];