From afab0af590c320a1d57e4ea1305a4ff83f988851 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 13 Dec 2019 16:08:16 +0000 Subject: [PATCH] Bug 24236: Fix pagination to use query_cgi This is still wrong, we should use page-numbers.inc, but that is a larger refactoring This patch fixes non-QueryParser searches by simple getting an using the escaped query (query_cgi) For QueryParser, we do what the QP code does, just uri escape the query - the way that SimpleSearch does the query parsing instead of the usual buildQuery suggest to me that we should probably switch all of this to use the general Zebra search. The issues with reservoir should be their own bug To test: 1 - Search for cat in cataloging search 2 - Get results and see you can paginate 3 - Search for "cat" 4 - Get results but subsequent pages empty 5 - Apply patch 6 - Repeat search for "cat" 7 - You can paginate 8 - Enable UseQueryParser syspref (don't worry about installing) 9 - Confirm can still search with quotes and paginate Signed-off-by: Nick Clemens Signed-off-by: George Williams Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit c2182118e130ac246b1f5ed790fb1659789e2fe5) Signed-off-by: Lucas Gass --- cataloguing/addbooks.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index 2082913862..b9ed6ff874 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -27,6 +27,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); +use URI::Escape; use C4::Auth; use C4::Biblio; use C4::Breeding; @@ -70,14 +71,16 @@ if ($query) { my $QParser; $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); my $builtquery; + my $query_cgi; my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); if ($QParser) { $builtquery = $query; + $query_cgi = "q=".uri_escape_utf8($query); } else { - ( undef, $builtquery, undef, undef, undef, undef, undef, undef, undef, undef ) = + ( undef, $builtquery, undef, $query_cgi, undef, undef, undef, undef, undef, undef ) = $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang ); } # find results @@ -101,7 +104,7 @@ if ($query) { total => $total_hits, query => $query, resultsloop => \@newresults, - pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?q=$query&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ), + pagination_bar => pagination_bar( "/cgi-bin/koha/cataloguing/addbooks.pl?$query_cgi&", getnbpages( $total_hits, $results_per_page ), $page, 'page' ), ); } -- 2.39.5