Use a per-version upgrade override
authorAlexander Ebert <ebert@woltlab.com>
Mon, 14 Oct 2024 12:30:54 +0000 (14:30 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 14 Oct 2024 12:30:54 +0000 (14:30 +0200)
See https://www.woltlab.com/community/thread/308245-pr%C3%BCfung-auf-systemkompatibilit%C3%A4t-fehlerhaft-bei-upgrade-5-4-6-0/

wcfsetup/install/files/lib/acp/form/PackageEnableUpgradeOverrideForm.class.php
wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php

index 5100122a5a847b8611308ddfa81d447ccbdcd794..f4311238423f06432008c2cdeca43036df92c446 100644 (file)
@@ -365,15 +365,24 @@ final class PackageEnableUpgradeOverrideForm extends AbstractFormBuilderForm
     {
         AbstractForm::save();
 
+        $overrideKey = \sprintf(
+            "%s\0upgradeOverride_%s",
+            PackageUpdateServer::class,
+            WCF::AVAILABLE_UPGRADE_VERSION,
+        );
+
         $formData = $this->form->getData();
         if ($formData['data']['enable']) {
             $this->isEnabled = true;
-            RegistryHandler::getInstance()->set('com.woltlab.wcf', PackageUpdateServer::class . "\0upgradeOverride", \TIME_NOW);
+            RegistryHandler::getInstance()->set('com.woltlab.wcf', $overrideKey, \TIME_NOW);
         } else {
             $this->isEnabled = false;
-            RegistryHandler::getInstance()->delete('com.woltlab.wcf', PackageUpdateServer::class . "\0upgradeOverride");
+            RegistryHandler::getInstance()->delete('com.woltlab.wcf', $overrideKey);
         }
 
+        // Clear the legacy override.
+        RegistryHandler::getInstance()->delete('com.woltlab.wcf', PackageUpdateServer::class . "\0upgradeOverride");
+
         PackageUpdateServer::resetAll();
 
         $this->form->cleanup();
index a337710f89701e4b07331e081567b89eaff2d285..f293548e2daa9f82d56f1ff15f81d3be5b651a6f 100644 (file)
@@ -420,14 +420,19 @@ class PackageUpdateServer extends DatabaseObject
             return false;
         }
 
-        $override = RegistryHandler::getInstance()->get('com.woltlab.wcf', self::class . "\0upgradeOverride");
+        $overrideKey = \sprintf(
+            "%s\0upgradeOverride_%s",
+            self::class,
+            WCF::AVAILABLE_UPGRADE_VERSION,
+        );
+        $override = RegistryHandler::getInstance()->get('com.woltlab.wcf', $overrideKey);
 
         if (!$override) {
             return false;
         }
 
         if ($override < TIME_NOW - 86400) {
-            RegistryHandler::getInstance()->delete('com.woltlab.wcf', self::class . "\0upgradeOverride");
+            RegistryHandler::getInstance()->delete('com.woltlab.wcf', $overrideKey);
 
             // Clear package list cache to actually stop the upgrade from happening.
             self::resetAll();