From 8d21dd98af08a76218fa374323e7a9eda7267274 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 30 May 2014 20:54:10 -0300 Subject: [PATCH] Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl This patch removes the use of smartmatch operators in the search code. Regards To+ Edit: this revision uses 'grep' instead of Lists::MoreUtils::any Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer Passes all tests and QA script. Tested search, no problems found. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Galen Charlton --- C4/Search.pm | 2 +- opac/opac-search.pl | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 5ac54c36aa..373c67c7fb 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -532,7 +532,7 @@ sub getRecords { foreach my $field (@fields) { my $data = $field->as_string( $subfield_letters, $facet->{sep} ); - unless ( $data ~~ @used_datas ) { + unless ( grep { /^$data$/ } @used_datas ) { push @used_datas, $data; $facets_counter->{ $facet->{idx} }->{$data}++; } diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 990cbd0835..cc6beb7b19 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -30,15 +30,12 @@ use Modern::Perl; use C4::Context; my $searchengine = C4::Context->preference("SearchEngine"); -for ( $searchengine ) { - when ( /^Solr$/ ) { - warn "We use Solr"; - require 'opac/search.pl'; - exit; - } - when ( /^Zebra$/ ) { +if ( $searchengine =~ /^Solr$/ ) { + warn "We use Solr"; + require 'opac/search.pl'; + exit; +} elsif ( $searchengine =~ /^Zebra$/ ) { - } } use C4::Output; @@ -360,7 +357,7 @@ my @allowed_sortby = qw /acqdate_asc acqdate_dsc author_az author_za call_number @sort_by = $cgi->param('sort_by'); $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by); foreach my $sort (@sort_by) { - if ( $sort ~~ @allowed_sortby ) { + if ( grep { /^$sort$/ } @allowed_sortby ) { $template->param($sort => 1); } } -- 2.39.5