From 360161b1fcc83811f09ffbdf86cc9a2df271528e Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 8 Jul 2025 21:28:16 +0200 Subject: [PATCH] SearchService.php: handle filters getting trimmed into oblivion --- inc/Service/SearchService.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/inc/Service/SearchService.php b/inc/Service/SearchService.php index dafceb9e..b3b1e086 100644 --- a/inc/Service/SearchService.php +++ b/inc/Service/SearchService.php @@ -116,11 +116,14 @@ class SearchService { } } - // Interword wildcards - $interword = \min(\count($fragments) - 1, 0); - // Wildcards over the total length of the word. Ergo the number of fragments minus 1. - $perc = $interword / $total_len * 100; - $wildcard_weight = $perc + \count($fragments) * 2; + $wildcard_weight = 0; + if (!empty($acc) && $total_len >= 0) { + // Interword wildcards + $interword = \min(\count($fragments) - 1, 0); + // Wildcards over the total length of the word. Ergo the number of fragments minus 1. + $perc = $interword / $total_len * 100; + $wildcard_weight = $perc + \count($fragments) * 2; + } return [ $acc, $total_len, $wildcard_weight ]; }