From 5906df65411bff67a7c89ee771ad21729c850b70 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 11 Jun 2021 17:10:56 +0200 Subject: [PATCH] Support adding WoltLab package server login credentials to dev config file --- .../lib/system/devtools/DevtoolsSetup.class.php | 12 ++++++++++++ .../PackageInstallationDispatcher.class.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php b/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php index 274a068542..ba35890fdf 100644 --- a/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php +++ b/wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php @@ -157,6 +157,18 @@ class DevtoolsSetup extends SingletonFactory return (isset($this->configuration['configuration']['devtools']) && !empty($this->configuration['configuration']['devtools']['importFromPath'])) ? $this->configuration['configuration']['devtools']['importFromPath'] : ''; } + /** + * Returns the login data for the WoltLab package servers. + */ + public function getPackageServerLogin(): array + { + if (isset($this->configuration['packageServerLogin']['username']) && $this->configuration['packageServerLogin']['password']) { + return $this->configuration['packageServerLogin']; + } + + return []; + } + /** * Returns the raw configuration data. * diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 894519bca4..6e628956fa 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -397,6 +397,20 @@ class PackageInstallationDispatcher 'path' => $importPath, ]))->executeAction(); } + + $packageServerLogin = DevtoolsSetup::getInstance()->getPackageServerLogin(); + if (!empty($packageServerLogin)) { + // All update servers installed at this point are only our own servers for which the same + // login data can be used. + $sql = "UPDATE wcf1_package_update_server + SET loginUsername = ?, + loginPassword = ?"; + $statement = WCF::getDB()->prepare($sql); + $statement->execute([ + $packageServerLogin['username'], + $packageServerLogin['password'], + ]); + } } /** -- 2.20.1