From 8bf971217ce341c2ae877b571fbe9c9a2464dd1a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 18 Aug 2026 12:48:14 +0000 Subject: [PATCH] Bug 43320: Don't quoted already quoted searches and add feedback Bug 31213 added a quoted search when no results were found, this patch builds on that to: 1 - Notify the user when their search is repeated quoted 2 - Not repeat a search when already quoted To test: 0 - Set system preferences RedirectToSoleResult to 'Don't redirect' IntranetAddMastheadLibraryPulldown to Show IntranetCatalogSearchPulldown to Show 1 - Add the sample records to your catalog 2 - Search for the quoted phrase "happy family big" in the 'title' index 3 - Note you get a result 4 - Check the record - the phrase is not found, but the record contains all the terms 5 - Search for the unquoted phrase: 6:20 man 6 - Confirm search is quoted and result found 7 - Apply patch, restart all 8 - Repeat 5 9 - Confirm you are now told search was quoted and result found 10 - Repeat 2 11 - Confirm no result found, no notice of repeated search Signed-off-by: Phil Ringnalda Signed-off-by: Matt Blenkinsop Signed-off-by: Lucas Gass --- catalogue/search.pl | 7 ++++++- .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index a162737303..2c172d5675 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -556,7 +556,8 @@ if ( $@ || $error ) { } my $hits = $results_hashref->{$server}->{"hits"} // 0; -if ( $hits == 0 && $basic_search ) { +if ( $hits == 0 && $basic_search && $operands[0] !~ /^\".*\"$/ ) { + my $og_query = $query_desc; $operands[0] = '"' . $operands[0] . '"'; #quote it ## I. BUILD THE QUERY ( @@ -585,6 +586,10 @@ if ( $hits == 0 && $basic_search ) { }; my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0; if ($quoted_hits) { + $template->param( + quoted_hits => 1, + og_query => $og_query, + ); $results_hashref->{$server} = $quoted_results_hashref->{$server}; $hits = $quoted_hits; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 417bf83005..e7bc078cbf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -72,6 +72,12 @@

Search results

[% IF ( total ) %] + [% IF quoted_hits %] +

+ No result(s) found for your original query: [% og_query %]
+ Your search was retried, quoted +

+ [% END %]

[% total | html %] result(s) found [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF limit_desc %]