Support adding WoltLab package server login credentials to dev config file
authorMatthias Schmidt <gravatronics@live.com>
Fri, 11 Jun 2021 15:10:56 +0000 (17:10 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 11 Jun 2021 15:15:20 +0000 (17:15 +0200)
wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index 274a068542b01c12fa509da3bece1006baf4e79b..ba35890fdf76fe314fb3e84dbe154bc5dad376b2 100644 (file)
@@ -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.
      *
index 894519bca46d39d55f9fbc327478a98d546d0671..6e628956fa7bc928be9a00c5ba3f3f10122c22b5 100644 (file)
@@ -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'],
+            ]);
+        }
     }
 
     /**