Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl
authorTomas Cohen Arazi <tomascohen@gmail.com>
Fri, 30 May 2014 23:54:10 +0000 (20:54 -0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 7 Jul 2014 13:16:36 +0000 (10:16 -0300)
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 <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Tested search, no problems found.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Search.pm
opac/opac-search.pl

index 86f2c59..1b5c6fa 100644 (file)
@@ -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}++;
                                     }
index 990cbd0..cc6beb7 100755 (executable)
@@ -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);
     }
 }