From 46845ce6d719e0479ff947a98b845e74bb2357ed Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Fri, 31 Oct 2025 20:07:07 +0700 Subject: [PATCH] improve initTrackerUrl() --- nexus/Install/Install.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index b9fd5cbd..5a7a89d2 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -764,11 +764,25 @@ class Install $searchBoxRep->migrateToModeRelated(); } - public function initTrackerUrl(): void + /** + * 初始化,注意这里不能使用 get_tracker_schema_and_host()。里面会调用 TrackerUrl, 这本来就是要往里面插入数据 + * + * @param string $scene install or update + * @return void + */ + public function initTrackerUrl(string $scene): void { - $announceUrl = get_setting("security.https_announce_url"); + if ($scene == "update") { + $announceUrl = get_setting("security.https_announce_url"); + if (empty($announceUrl)) { + $announceUrl = get_setting("basic.announce_url"); + } + } if (empty($announceUrl)) { - $announceUrl = get_setting("basic.announce_url"); + $announceUrl = sprintf( + "%s/%s", + trim($_SERVER['HTTP_HOST'], '/'), trim(DEFAULT_TRACKER_URI, '/') + ); } if (!str_starts_with($announceUrl, "http")) { $announceUrl = (isHttps() ? "https://" : "http://"). $announceUrl;