Author: Luffy (sy-records)
Committer: GitHub (web-flow)
Pusher: saundefined
Date: 2024-12-30T16:02:16+03:00

Commit: 
https://github.com/php/web-php/commit/a3dd12141762060f401dd935bc59022c45bde051
Raw diff: 
https://github.com/php/web-php/commit/a3dd12141762060f401dd935bc59022c45bde051.diff

Fix loadIndexWithFallback failed (#1193)

Fix #1122
Fix #1192

Changed paths:
  M  js/search-index.php
  M  js/search.js


Diff:

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

Reply via email to