From 9f4dd1c149f69b52d952837dd62ea79cbf4ab9f6 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 21 Apr 2020 20:22:08 +0100 Subject: [PATCH] libsearchengine/didyoumean: fix infinite loop --- modules/lib-search-engine.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/lib-search-engine.php b/modules/lib-search-engine.php index 3c7ca7f..0b82abf 100644 --- a/modules/lib-search-engine.php +++ b/modules/lib-search-engine.php @@ -677,7 +677,9 @@ class search error_log("[stas_parse/didyoumean] Now looking at #$i: ".var_export($result["terms"][$i], true)."(total count: $terms_count)"); if($result["terms"][$i]["exact"] || // Skip exact-only $result["terms"][$i]["weight"] < 1 || // Skip stop & irrelevant words - self::invindex_term_exists($result["terms"][$i]["term"])) continue; + self::invindex_term_exists($result["terms"][$i]["term"])) { + $i++; continue; + } // It's not a stop word or in the index, try and correct it // self::didyoumean_correct auto-loads the didyoumean index on-demand @@ -685,7 +687,7 @@ class search // Make a note if we fail to correct a term if(!is_string($correction)) { $result["terms"][$i]["corrected"] = false; - continue; + $i++; continue; } $result["terms"][$i]["term_before"] = $result["terms"][$i]["term"];