Merge branch '1.9' into php8

This commit is contained in:
xiaomlove
2025-11-02 21:59:30 +07:00
5 changed files with 36 additions and 18 deletions
+33
View File
@@ -3,6 +3,7 @@
namespace Nexus\Install;
use App\Models\Setting;
use App\Models\TrackerUrl;
use App\Models\User;
use App\Repositories\SearchBoxRepository;
use App\Repositories\UserRepository;
@@ -765,4 +766,36 @@ class Install
$searchBoxRep->migrateToModeRelated();
}
/**
* 初始化,注意这里不能使用 get_tracker_schema_and_host()。里面会调用 TrackerUrl, 这本来就是要往里面插入数据
*
* @param string $scene install or update
* @return void
*/
public function initTrackerUrl(string $scene): void
{
if ($scene == "update") {
$announceUrl = get_setting("security.https_announce_url");
if (empty($announceUrl)) {
$announceUrl = get_setting("basic.announce_url");
}
}
if (empty($announceUrl)) {
$announceUrl = sprintf(
"%s/%s",
trim($_SERVER['HTTP_HOST'], '/'), trim(DEFAULT_TRACKER_URI, '/')
);
}
if (!str_starts_with($announceUrl, "http")) {
$announceUrl = (isHttps() ? "https://" : "http://"). $announceUrl;
}
TrackerUrl::query()->create([
"url" => $announceUrl,
"enabled" => 1,
"is_default" => 1,
]);
TrackerUrl::saveUrlCache();
$this->doLog("[initTrackerUrl] $announceUrl success.");
}
}