From 07addc1f421769f09784760dedd9e6211b22ce95 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Wed, 9 Apr 2025 00:59:57 +0000 Subject: [PATCH] Bug 39589: OPAC search returns 'No results found' despite existing matching records This issue occurs when the records on the first page of results are not displayed. The message "No results found" is shown, and it is not possible to access records on other pages. To test 1. Set the following system preferences: OPACnumSearchResults to 5 OpacHiddenItemsHidesRecord to Hide OpacHiddenItems to withdrawn: [1] 2. Create 6 bibliographic records with the following titles: "notice test 1" "notice test 2" "notice test 3" "notice test 4" "notice test 5" "notice test 6" 3. For the first 5 records, add an item with Withdrawn status. 4. For "notice test 6", add an item with Available status. 5. In the OPAC interface, search for "notice test". 6. Apply the patch 7. Repeat step 4 ---> The results table is now shown with the message: "Search results on this page are not available." ---> You can now access the second page and see "notice test 6" --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 7 +++++++ opac/opac-search.pl | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 2cfd946085..1d75aa3088 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -192,6 +192,7 @@
[% INCLUDE 'page-numbers.inc' %]
+ [% UNLESS no_result %] [% UNLESS tag %]
@@ -223,13 +224,18 @@
[% END # /UNLESS tag %] + [% END %]
[% INCLUDE 'result-batch-controls.inc' results=1 %] + [% IF no_result %] +

Search results on this page are not available.

+ [% END %]
+ [% UNLESS no_result %] @@ -418,6 +424,7 @@ [% END # / FOREACH SEARCH_RESULT %]
Results
+ [% END %] diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 9f906784c9..4e105eaa2a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -670,7 +670,9 @@ for ( my $i = 0 ; $i < @servers ; $i++ ) { $search_context, $query_desc, $hits, $results_per_page, $offset, $scan, $results_hashref->{$server}->{"RECORDS"}, $variables ); - $hits = 0 unless @newresults; + unless (@newresults) { + $template->param( no_result => 1 ); + } my $art_req_itypes; if ( C4::Context->preference('ArticleRequests') ) { -- 2.34.1