From 1aa52c755e2f34ce5020a9b7a331a929e961337f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Jan 2024 16:54:49 +0100 Subject: [PATCH] Bug 35578: Simplify the code using intersect Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 602521a80aa850ae9f5d53953f5a8696e57f9b73) Signed-off-by: Fridolin Somers --- opac/opac-authorities-home.pl | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl index ba011bd014..9e617485d2 100755 --- a/opac/opac-authorities-home.pl +++ b/opac/opac-authorities-home.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use URI::Escape qw( uri_escape_utf8 ); +use Array::Utils qw(intersect); + use C4::Auth qw( get_template_and_user ); use C4::Context; @@ -55,20 +57,10 @@ if ( $op eq "do_search" ) { my @value = $query->multi_param('value'); $value[0] ||= q||; - my $valid_marc_list = { - "all" => 1, - "match" => 1, - "mainentry" => 1, - }; - my @marclist = (); - foreach my $entry (@input_marclist) { - if ( $valid_marc_list->{$entry} ) { - push( @marclist, $entry ); - } - } - if ( !@marclist ) { - push( @marclist, 'all' ); - } + # validation of "Where" + my @valid_marc_list = qw( all match mainentry ); + my @marclist = intersect( @input_marclist, @valid_marc_list ); + @marclist = ('all') unless @marclist; my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); -- 2.39.5