From 31b7e7405506ff78ae86eba6089a7451c0a83316 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 25 Sep 2020 15:15:38 +0200 Subject: [PATCH] Bug 26537: Fix search when no term in value_builder/unimarc_field_4XX.pl Cataloguing plugin value_builder/unimarc_field_4XX.pl has an itemtype filter. It does not work when used without a search term. Test plan : 1) Be sure search on itemtype return some results 2) Use cataloguing plugin unimarc_field_4XX.pl 3) Enter no search term and select an itemtype 4) Check you get correct results 5) Enter a search term and dont select an itemtype 6) Check you get correct results 7) Enter a search term and select an itemtype 8) Check you get correct results --- cataloguing/value_builder/unimarc_field_4XX.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl index e15768780e..c9573cad8a 100755 --- a/cataloguing/value_builder/unimarc_field_4XX.pl +++ b/cataloguing/value_builder/unimarc_field_4XX.pl @@ -357,11 +357,13 @@ sub plugin { my $itype = $query->param('itype'); my $startfrom = $query->param('startfrom'); my $resultsperpage = $query->param('resultsperpage') || 20; + my $searchquery = ''; my $orderby; - my $op = 'and'; - $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype; + $searchquery .= 'kw:'.$search if $search; + $searchquery .= ' AND ' if $search && $itype; + $searchquery .= 'mc-itemtype:'.$itype if $itype; my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); - my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage ); + my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($searchquery, $startfrom * $resultsperpage, $resultsperpage ); if (defined $errors ) { $results = []; } -- 2.27.0