Ensure that the official package servers exist
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 20 Aug 2020 13:18:46 +0000 (15:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 20 Aug 2020 13:18:46 +0000 (15:18 +0200)
wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php

index 96686c23cb239f2132597c8d561d78bf2701f8a8..929269be51a16eb165c74167ad6ae4a09046bb7e 100644 (file)
@@ -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;
        }
        
        /**