Skip to content

Commit

Permalink
Fix loadIndexWithFallback failed (php#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Dec 30, 2024
1 parent 0f75480 commit a3dd121
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions js/search-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a3dd121

Please sign in to comment.