From 79c48c3ad9254ce34fbe2e59cc2993aca6ac1775 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 20 Aug 2020 15:18:46 +0200 Subject: [PATCH] Ensure that the official package servers exist --- .../server/PackageUpdateServer.class.php | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index 96686c23cb..929269be51 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -73,16 +73,37 @@ class PackageUpdateServer extends DatabaseObject { } $list = new PackageUpdateServerList(); - $list->getConditionBuilder()->add("isDisabled = ?", [0]); $list->readObjects(); + $woltlabUpdateServer = null; + $woltlabStoreServer = null; + $results = []; + foreach ($list as $packageServer) { + if ($packageServer->isWoltLabUpdateServer()) $woltlabUpdateServer = $packageServer; + if ($packageServer->isWoltLabStoreServer()) $woltlabStoreServer = $packageServer; + if ($packageServer->isDisabled) continue; + + $results[] = $packageServer; + } + + if (!$woltlabUpdateServer) { + $results[] = PackageUpdateServerEditor::create([ + 'serverURL' => 'http://update.woltlab.com/'.\wcf\getMinorVersion().'/', + ]); + } + if (!$woltlabStoreServer) { + $results[] = PackageUpdateServerEditor::create([ + 'serverURL' => 'http://store.woltlab.com/'.\wcf\getMinorVersion().'/', + ]); + } + if (ENABLE_ENTERPRISE_MODE) { - return array_filter($list->getObjects(), function (PackageUpdateServer $server) { + return array_filter($results, function (PackageUpdateServer $server) { return $server->isWoltLabStoreServer() || $server->isTrustedServer(); }); } - return $list->getObjects(); + return $results; } /** -- 2.20.1