1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Fix loadIndexWithFallback failed (#1193)

Fix #1122
Fix #1192
This commit is contained in:
Luffy
2024-12-30 21:02:16 +08:00
committed by GitHub
parent 0f75480f20
commit a3dd121417
2 changed files with 5 additions and 10 deletions

View File

@@ -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(

View File

@@ -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;
}