Support explicit `*` for excluded parameters
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 21 Mar 2022 12:16:01 +0000 (13:16 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Mon, 21 Mar 2022 12:16:01 +0000 (13:16 +0100)
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php
wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php

index 2c7ff748fb90ce5dbfbdc837535b0d977ad5f825..73c190b869b78307587a3dc02e27cf4d80886991 100644 (file)
@@ -935,13 +935,12 @@ class PackageArchive
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute([$this->packageInfo['name']]);
         while ($row = $statement->fetchArray()) {
-            if (!empty($row['excludedPackageVersion'])) {
-                if (Package::compareVersion($this->packageInfo['version'], $row['excludedPackageVersion'], '<')) {
-                    continue;
-                }
+            if (
+                $row['excludedPackageVersion'] === '*'
+                || Package::compareVersion($this->packageInfo['version'], $row['excludedPackageVersion'], '>=')
+            ) {
+                $conflictedPackages[$row['packageID']] = new Package(null, $row);
             }
-
-            $conflictedPackages[$row['packageID']] = new Package(null, $row);
         }
 
         return $conflictedPackages;
@@ -970,21 +969,17 @@ class PackageArchive
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute($conditions->getParameters());
             while ($row = $statement->fetchArray()) {
-                if (!empty($excludedPackages[$row['package']])) {
-                    if (
-                        $excludedPackages[$row['package']] !== '*'
-                        && Package::compareVersion(
-                            $row['packageVersion'],
-                            $excludedPackages[$row['package']],
-                            '<'
-                        )
-                    ) {
-                        continue;
-                    }
+                if (
+                    $excludedPackages[$row['package']] === '*'
+                    || Package::compareVersion(
+                        $row['packageVersion'],
+                        $excludedPackages[$row['package']],
+                        '>'
+                    )
+                ) {
                     $row['excludedPackageVersion'] = $excludedPackages[$row['package']];
+                    $conflictedPackages[$row['packageID']] = new Package(null, $row);
                 }
-
-                $conflictedPackages[$row['packageID']] = new Package(null, $row);
             }
         }
 
index ee35ce079a66e89aad0186a31a0879db665922c0..e294305b31fc95d6a2f1ddc1f9c2958e7b1f7983 100644 (file)
@@ -608,7 +608,7 @@ class PackageInstallationDispatcher
                 $statement->execute([
                     $this->queue->packageID,
                     $excludedPackage['name'],
-                    !empty($excludedPackage['version']) ? $excludedPackage['version'] : '',
+                    $excludedPackage['version'],
                 ]);
             }
         }
index dc7e6ef2cb20980aa6c8debc5d4ce993123a5ad2..4c434b88853519b75913641e57747f1170577801 100644 (file)
@@ -420,10 +420,11 @@ class PackageInstallationScheduler
                         ];
 
                         // check version
-                        if (!empty($row['excludedPackageVersion'])) {
-                            if (Package::compareVersion($row['packageVersion'], $row['excludedPackageVersion'], '<')) {
-                                continue;
-                            }
+                        if (
+                            $row['excludedPackageVersion'] !== '*'
+                            && Package::compareVersion($row['packageVersion'], $row['excludedPackageVersion'], '<')
+                        ) {
+                            continue;
                         }
 
                         $excludedPackages[] = [
@@ -457,7 +458,8 @@ class PackageInstallationScheduler
                         if (!empty($row['excludedPackageVersion'])) {
                             // check version
                             if (
-                                Package::compareVersion(
+                                $row['excludedPackageVersion'] !== "*"
+                                && Package::compareVersion(
                                     $packageInstallation['newVersion'],
                                     $row['excludedPackageVersion'],
                                     '<'
index d85eac39e95ad70d4d07eb1daea7be8ca63b38c2..42a2fb4e8a16dc13731134049ff7bc5a1d3a13f4 100644 (file)
@@ -607,7 +607,7 @@ class PackageUpdateDispatcher extends SingletonFactory
                         $excludedPackagesParameters[] = [
                             'packageUpdateVersionID' => $packageUpdateVersionID,
                             'excludedPackage' => $excludedIdentifier,
-                            'excludedPackageVersion' => $exclusion['version'] ?? '',
+                            'excludedPackageVersion' => $exclusion['version'],
                         ];
                     }
                 }
index ee277e96618b78f6067074f8c7575f72d0c5a379..dda2d2c4c0ac02b7fbd4c4319c757fd50d041d44 100644 (file)
@@ -354,26 +354,26 @@ class PackageValidationArchive implements \RecursiveIterator
                 if (isset(self::$excludedPackages[$excludingPackage][$package])) {
                     for ($i = 0, $count = \count(self::$excludedPackages[$excludingPackage][$package]); $i < $count; $i++) {
                         if (
-                            Package::compareVersion(
+                            self::$excludedPackages[$excludingPackage][$package][$i] === '*'
+                            || Package::compareVersion(
                                 $packageVersion,
                                 self::$excludedPackages[$excludingPackage][$package][$i],
-                                '<'
+                                '>='
                             )
                         ) {
-                            continue;
+                            $excludingPackages[] = new Package(null, $row);
                         }
-
-                        $excludingPackages[] = new Package(null, $row);
                     }
 
                     continue;
                 }
             } else {
-                if (Package::compareVersion($packageVersion, $row['excludedPackageVersion'], '<')) {
-                    continue;
+                if (
+                    $row['excludedPackageVersion'] === '*'
+                    || Package::compareVersion($packageVersion, $row['excludedPackageVersion'], '>=')
+                ) {
+                    $excludingPackages[] = new Package(null, $row);
                 }
-
-                $excludingPackages[] = new Package(null, $row);
             }
         }
 
@@ -408,7 +408,8 @@ class PackageValidationArchive implements \RecursiveIterator
 
                 for ($i = 0, $count = \count(self::$excludedPackages[$package][$excludedPackage]); $i < $count; $i++) {
                     if (
-                        Package::compareVersion(
+                        self::$excludedPackages[$package][$excludedPackage][$i] !== "*"
+                        && Package::compareVersion(
                             $version,
                             self::$excludedPackages[$package][$excludedPackage][$i],
                             '<'