Force exclusion of Core `6.0.0 Alpha 1` for packages with API compatibility
authorAlexander Ebert <ebert@woltlab.com>
Wed, 13 Nov 2019 00:19:18 +0000 (01:19 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 13 Nov 2019 00:19:18 +0000 (01:19 +0100)
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php

index f6f1711d15e98977ee87e20ed19a15f4571ad333..1b9323280e65a305f63455febe421f54475d1d9c 100644 (file)
@@ -552,6 +552,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                                        }
                                        
                                        // register compatibility versions of this update package version.
+                                       // @deprecated 5.2
                                        if (isset($versionData['compatibility'])) {
                                                foreach ($versionData['compatibility'] as $version) {
                                                        $compatibilityInserts[] = [
@@ -559,6 +560,31 @@ class PackageUpdateDispatcher extends SingletonFactory {
                                                                '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($compatibilityInserts)) {
+                                                       if (!isset($versionData['excludedPackages'])) $versionData['excludedPackages'] = [];
+                                                       $excludeCore60 = '6.0.0 Alpha 1';
+                                                       
+                                                       $coreExclude = null;
+                                                       $versionData['excludedPackages'] = array_filter($versionData['excludedPackages'], function($excludedPackage) use (&$coreExclude) {
+                                                               if ($excludedPackage['excludedPackage'] === 'com.woltlab.wcf') {
+                                                                       $coreExclude = $excludedPackage['excludedPackageVersion'];
+                                                                       return false;
+                                                               }
+                                                               
+                                                               return true;
+                                                       });
+                                                       
+                                                       if ($coreExclude === null || Package::compareVersion($coreExclude, $excludeCore60, '>')) {
+                                                               $versionData['excludedPackages'][] = [
+                                                                       'packageUpdateVersionID' => $packageUpdateVersionID,
+                                                                       'excludedPackage' => 'com.woltlab.wcf',
+                                                                       'excludedPackageVersion' => $excludeCore60,
+                                                               ];
+                                                       }
+                                               }
                                        }
                                }
                        }
@@ -633,6 +659,7 @@ class PackageUpdateDispatcher extends SingletonFactory {
                }
                
                // insert compatibility versions
+               // @deprecated 5.2
                if (!empty($compatibilityInserts)) {
                        $sql = "INSERT INTO     wcf".WCF_N."_package_update_compatibility
                                                (packageUpdateVersionID, version)