Do not store package compatibility from update servers within the database
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 8 Jul 2021 10:31:49 +0000 (12:31 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 8 Jul 2021 10:35:48 +0000 (12:35 +0200)
These do not appear to be used anywhere and the official package servers do not
expose them either, making them effectively empty even in current versions.

see #4371

wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_clearPackageCompatibility.php
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php
wcfsetup/setup/db/install.sql

index 487cb7473447ade694927463a7a55ac65be005e9..389de518b5f194379c525d171dc38584cb3bc3dd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Clear the wcf1_package_compatibility table.
+ * Clear the wcf1_package_(update_)?compatibility table.
  *
  * see https://github.com/WoltLab/WCF/pull/4371
  *
@@ -16,3 +16,7 @@ use wcf\system\WCF;
 $sql = "DELETE FROM wcf1_package_compatibility";
 $statement = WCF::getDB()->prepare($sql);
 $statement->execute();
+
+$sql = "DELETE FROM wcf1_package_update_compatibility";
+$statement = WCF::getDB()->prepare($sql);
+$statement->execute();
index 5e1b9fe01799084b41a0d322b67dfd9581c70938..6e4fb2116785105dff0708ed6dca4aa278ab4269 100644 (file)
@@ -524,7 +524,7 @@ class PackageUpdateDispatcher extends SingletonFactory
      */
     protected function savePackageUpdates(array &$allNewPackages, $packageUpdateServerID)
     {
-        $excludedPackagesParameters = $optionalInserts = $requirementInserts = $compatibilityInserts = [];
+        $excludedPackagesParameters = $optionalInserts = $requirementInserts = [];
         $sql = "INSERT INTO wcf" . WCF_N . "_package_update
                             (packageUpdateServerID, package, packageName, packageDescription, author, authorURL, isApplication, pluginStoreFileID)
                 VALUES      (?, ?, ?, ?, ?, ?, ?, ?)";
@@ -630,45 +630,35 @@ class PackageUpdateDispatcher extends SingletonFactory
                     }
                 }
 
-                // @deprecated 5.2
-                if (isset($versionData['compatibility'])) {
-                    foreach ($versionData['compatibility'] as $version) {
-                        $compatibilityInserts[] = [
-                            'packageUpdateVersionID' => $packageUpdateVersionID,
-                            'version' => $version,
-                        ];
+                // The API compatibility versions are deprecated, any package that exposes them must
+                // exclude at most `com.woltlab.wcf` in version `6.0.0 Alpha 1`.
+                if (!empty($versionData['compatibility'])) {
+                    if (!isset($versionData['excludedPackages'])) {
+                        $versionData['excludedPackages'] = [];
                     }
+                    $excludeCore60 = '6.0.0 Alpha 1';
 
-                    // The API compatibility versions are deprecated, any package that exposes them must
-                    // exclude at most `com.woltlab.wcf` in version `6.0.0 Alpha 1`.
-                    if (!empty($compatibilityInserts)) {
-                        if (!isset($versionData['excludedPackages'])) {
-                            $versionData['excludedPackages'] = [];
-                        }
-                        $excludeCore60 = '6.0.0 Alpha 1';
+                    $coreExclude = null;
+                    $versionData['excludedPackages'] = \array_filter(
+                        $versionData['excludedPackages'],
+                        static function ($excludedPackage, $excludedVersion) use (&$coreExclude) {
+                            if ($excludedPackage === 'com.woltlab.wcf') {
+                                $coreExclude = $excludedVersion;
 
-                        $coreExclude = null;
-                        $versionData['excludedPackages'] = \array_filter(
-                            $versionData['excludedPackages'],
-                            static function ($excludedPackage, $excludedVersion) use (&$coreExclude) {
-                                if ($excludedPackage === 'com.woltlab.wcf') {
-                                    $coreExclude = $excludedVersion;
-
-                                    return false;
-                                }
+                                return false;
+                            }
 
-                                return true;
-                            },
-                            \ARRAY_FILTER_USE_BOTH
-                        );
+                            return true;
+                        },
+                        \ARRAY_FILTER_USE_BOTH
+                    );
 
-                        if ($coreExclude === null || Package::compareVersion($coreExclude, $excludeCore60, '>')) {
-                            $versionData['excludedPackages'][] = [
-                                'packageUpdateVersionID' => $packageUpdateVersionID,
-                                'excludedPackage' => 'com.woltlab.wcf',
-                                'excludedPackageVersion' => $excludeCore60,
-                            ];
-                        }
+                    if ($coreExclude === null || Package::compareVersion($coreExclude, $excludeCore60, '>')) {
+                        $versionData['excludedPackages'][] = [
+                            'packageUpdateVersionID' => $packageUpdateVersionID,
+                            'excludedPackage' => 'com.woltlab.wcf',
+                            'excludedPackageVersion' => $excludeCore60,
+                        ];
                     }
                 }
             }
@@ -735,22 +725,6 @@ class PackageUpdateDispatcher extends SingletonFactory
             }
             WCF::getDB()->commitTransaction();
         }
-
-        // @deprecated 5.2
-        if (!empty($compatibilityInserts)) {
-            $sql = "INSERT INTO wcf" . WCF_N . "_package_update_compatibility
-                                (packageUpdateVersionID, version)
-                    VALUES      (?, ?)";
-            $statement = WCF::getDB()->prepareStatement($sql);
-            WCF::getDB()->beginTransaction();
-            foreach ($compatibilityInserts as $versionData) {
-                $statement->execute([
-                    $versionData['packageUpdateVersionID'],
-                    $versionData['version'],
-                ]);
-            }
-            WCF::getDB()->commitTransaction();
-        }
     }
 
     /**
index f88311372677bdc69c40b9807fe6bcb2d6942927..98f7c4ff57e711c826aa3cfe1f84c85b52add0cb 100644 (file)
@@ -1026,6 +1026,7 @@ CREATE TABLE wcf1_package_update (
        UNIQUE KEY packageUpdateServerID (packageUpdateServerID, package)
 );
 
+-- @deprecated
 DROP TABLE IF EXISTS wcf1_package_update_compatibility;
 CREATE TABLE wcf1_package_update_compatibility (
        packageUpdateVersionID INT(10) NOT NULL,