Add the update script to write the license file and sync credentials
authorAlexander Ebert <ebert@woltlab.com>
Tue, 26 Sep 2023 15:40:52 +0000 (17:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 26 Sep 2023 15:40:52 +0000 (17:40 +0200)
com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0.0.rc.1.php [deleted file]
wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_license.php [new file with mode: 0644]

index 77c86e5e3415fac52500b389f1258fcf787ee9f0..2e0a1992641884cb77f8e6b5564def18e13ac19c 100644 (file)
@@ -123,6 +123,7 @@ tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_favicon.php</instruction>
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_trophies.php</instruction>
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_removeDownloadedGravatars.php</instruction>
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_license.php</instruction>
 
                <!-- Clean Up. -->
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_removeLegacyAppConfig.php</instruction>
@@ -130,6 +131,12 @@ tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \
                <instruction type="templateDelete" />
        </instructions>
 
+       <!--
+               Include in the update RC 1 → RC 2:
+               
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_6.0_license.php</instruction>
+       -->
+
        <instructions type="update" fromversion="6.0.0 Beta 4">
                <instruction type="acpTemplate">acptemplates_update.tar</instruction>
                <instruction type="file">files_update.tar</instruction>
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0.0.rc.1.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0.0.rc.1.php
deleted file mode 100644 (file)
index 084d17b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-/**
- * Fixes the style variable value of `individualScssDarkMode`.
- *
- * @author Alexander Ebert
- * @copyright 2001-2023 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- */
-
-use wcf\system\WCF;
-
-// Follow-up for https://github.com/WoltLab/WCF/commit/ccf4bcc71444a0c75c7543483585706895b51bd8
-$sql = "UPDATE  wcf1_style_variable_value
-        SET     variableValueDarkMode = ?
-        WHERE   variableID = (
-                    SELECT  variableID
-                    FROM    wcf1_style_variable
-                    WHERE   variableName = ?
-                )";
-$statement = WCF::getDB()->prepare($sql);
-$statement->execute([null, 'individualScssDarkMode']);
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_license.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_license.php
new file mode 100644 (file)
index 0000000..c9a4afe
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * Validates the license credentials and writes the license file.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2023 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+
+use wcf\data\package\update\server\PackageUpdateServer;
+use wcf\data\package\update\server\PackageUpdateServerEditor;
+use wcf\system\package\license\LicenseApi;
+
+try {
+    // Side-effect: Writes the license file.
+    LicenseApi::fetchFromRemote();
+
+    // If we’re still here it means that the credentials are actually valid. Now
+    // we can check if the credentials for both servers are in sync, because
+    // traditionally users could use their account credentials to authenticate.
+    $updateServer = PackageUpdateServer::getWoltLabUpdateServer();
+    $storeServer = PackageUpdateServer::getPluginStoreServer();
+
+    if ($updateServer->getAuthData() !== $storeServer->getAuthData()) {
+        $authData = $updateServer->getAuthData();
+
+        (new PackageUpdateServerEditor($storeServer))->update([
+            'username' => $authData['username'],
+            'password' => $authData['password'],
+        ]);
+    }
+} catch (\Throwable) {
+    // This action must be silent, failing to execute is not an issue here.
+}