From 5c74bc3ae7bff00240e2b975a73ab2871c094193 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 26 Dec 2024 14:49:22 +0800 Subject: [PATCH 1/2] Fix loadIndexWithFallback failed --- js/search.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/search.js b/js/search.js index 1cc5447de9..6c486d30d9 100644 --- a/js/search.js +++ b/js/search.js @@ -137,11 +137,11 @@ const initPHPSearch = async (language) => { */ const loadIndexWithFallback = async () => { try { - const searchItems = await loadIndex(); - return searchItems; + return await loadIndex(); } catch (error) { if (language !== "en") { - return loadIndexWithFallback("en"); + language = "en"; + return loadIndexWithFallback(); } throw error; } From 0218953da1dec1df0975779fd0f7cb14a4bd1e08 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Thu, 26 Dec 2024 15:01:00 +0800 Subject: [PATCH 2/2] Fix lang value was always en --- js/search-index.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/js/search-index.php b/js/search-index.php index 7d2f50193d..9e76196dff 100644 --- a/js/search-index.php +++ b/js/search-index.php @@ -2,19 +2,14 @@ use phpweb\I18n\Languages; -$_GET["lang"] = "en"; -if (!isset($_GET["lang"])) { - header("Location: http://php.net"); - exit; -} +$lang = $_GET["lang"] ?? "en"; if (empty($_SERVER["DOCUMENT_ROOT"])) { $_SERVER["DOCUMENT_ROOT"] = __DIR__ . "/../"; } include __DIR__ . '/../include/prepend.inc'; -if (!isset(Languages::ACTIVE_ONLINE_LANGUAGES[$_GET["lang"]])) { +if (!isset(Languages::ACTIVE_ONLINE_LANGUAGES[$lang])) { header("Location: http://php.net"); } -$lang = $_GET["lang"]; /* $types = array(