Prevent the removal of the package servers for `5.3` to preserve the credentials
authorAlexander Ebert <ebert@woltlab.com>
Wed, 23 Dec 2020 17:12:16 +0000 (18:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 23 Dec 2020 17:12:16 +0000 (18:12 +0100)
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_packageServer.php

index d762d697603da31526cbaa8440d08c04abb499af..9aed26891f0638afae4c5a387afef7d131b0ee7a 100644 (file)
@@ -11,46 +11,13 @@ $sql = "SELECT  *
 $statement = WCF::getDB()->prepareStatement($sql);
 $statement->execute();
 
-// Try to extract authentication credentials from the previous package servers.
-$newServers = [
-       "update" => [
-               "loginUsername" => "",
-               "loginPassword" => "",
-       ],
-       "store" => [
-               "loginUsername" => "",
-               "loginPassword" => "",
-       ],
-];
-
 $deleteServerIDs = [];
 while ($row = $statement->fetchArray()) {
-       $deleteServerIDs[] = $row["packageUpdateServerID"];
-       
-       // Only use values from the "2019" servers to avoid dealing with outdated
-       // credentials that have never been updated.
-       $serverURL = $row["serverURL"];
-       if (preg_match("~^https?://update\.woltlab\.com/2019/~", $serverURL)) {
-               $newServers["update"]["loginUsername"] = $row["loginUsername"];
-               $newServers["update"]["loginPassword"] = $row["loginPassword"];
-       }
-       else if (preg_match("~^https?://store\.woltlab\.com/2019/~", $serverURL)) {
-               $newServers["store"]["loginUsername"] = $row["loginUsername"];
-               $newServers["store"]["loginPassword"] = $row["loginPassword"];
+       if (!preg_match("~^https?://(?:store|update)\.woltlab\.com/5\.3/~", $row["serverURL"])) {
+               $deleteServerIDs[] = $row["packageUpdateServerID"];
        }
-} 
+}
 
 if (!empty($deleteServerIDs)) {
        PackageUpdateServerEditor::deleteAll($deleteServerIDs);
 }
-
-// Add the new package servers.
-$sql = "INSERT INTO wcf" . WCF_N . "_package_update_server (serverURL, loginUsername, loginPassword) VALUES (?, ?, ?)";
-$statement = WCF::getDB()->prepareStatement($sql);
-foreach ($newServers as $server => $authData) {
-       $statement->execute([
-               "https://{$server}.woltlab.com/5.3/",
-               $authData["loginUsername"],
-               $authData["loginPassword"],
-       ]);
-}