From 131050798d2933c02cdb2de853ae62e51b55ad37 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 3 Sep 2014 09:49:41 +1200 Subject: [PATCH] Bug 12861 : Noisy warn in the error logs To test Hit a url like cgi-bin/koha/opac-authorities-home.pl?op=do_search&type=opac&operatorc=contains&marclistc=mainentry&and_orc=and&orderby=HeadingAsc&value=FIRECLAY Notice the warns in the error log Apply patch Reload the url Still works but no warns (cherry picked from commit c98d805e490a82b2ea9f3d4e0f7278640942ba6d) Signed-off-by: Chris Cormack Reformatted to fix error M Tompsett spotted Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy Instead of 10 warnings, I now have only 4 warnings. We're going in the right direction. Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b2ce6347e55c92c9974f64d272dedffda41e3b44) Signed-off-by: Chris Cormack --- C4/AuthoritiesMarc.pm | 70 +++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index e983159f63..3ae0ab9a48 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -140,33 +140,38 @@ sub SearchAuthorities { my $and=" \@and " ; my $q2; my $attr_cnt = 0; - for(my $i = 0 ; $i <= $#{$value} ; $i++) - { - if (@$value[$i]){ - if ( @$tags[$i] eq "mainmainentry" ) { - $attr = " \@attr 1=Heading-Main "; - } - elsif ( @$tags[$i] eq "mainentry" ) { - $attr = " \@attr 1=Heading "; - } - elsif ( @$tags[$i] eq "match" ) { - $attr = " \@attr 1=Match "; - } - elsif ( @$tags[$i] eq "match-heading" ) { - $attr = " \@attr 1=Match-heading "; - } - elsif ( @$tags[$i] eq "see-from" ) { - $attr = " \@attr 1=Match-heading-see-from "; - } - elsif ( @$tags[$i] eq "thesaurus" ) { - $attr = " \@attr 1=Subject-heading-thesaurus "; - } - else { # Assume any if no index was specified + for ( my $i = 0 ; $i <= $#{$value} ; $i++ ) { + if ( @$value[$i] ) { + if ( @$tags[$i] ) { + if ( @$tags[$i] eq "mainmainentry" ) { + $attr = " \@attr 1=Heading-Main "; + } + elsif ( @$tags[$i] eq "mainentry" ) { + $attr = " \@attr 1=Heading "; + } + elsif ( @$tags[$i] eq "match" ) { + $attr = " \@attr 1=Match "; + } + elsif ( @$tags[$i] eq "match-heading" ) { + $attr = " \@attr 1=Match-heading "; + } + elsif ( @$tags[$i] eq "see-from" ) { + $attr = " \@attr 1=Match-heading-see-from "; + } + elsif ( @$tags[$i] eq "thesaurus" ) { + $attr = " \@attr 1=Subject-heading-thesaurus "; + } + else { # Assume any if no index was specified + $attr = " \@attr 1=Any "; + } + } #if @$tags[$i] + else { # Assume any if no index was specified $attr = " \@attr 1=Any "; } + if ( @$operator[$i] eq 'is' ) { $attr .= " \@attr 4=1 \@attr 5=100 " - ; ##Phrase, No truncation,all of subfield field must match + ; ##Phrase, No truncation,all of subfield field must match } elsif ( @$operator[$i] eq "=" ) { $attr .= " \@attr 4=107 "; #Number Exact match @@ -177,24 +182,25 @@ sub SearchAuthorities { } elsif ( @$operator[$i] eq "exact" ) { $attr .= " \@attr 4=1 \@attr 5=100 \@attr 6=3 " - ; ##Phrase, No truncation,all of subfield field must match + ; ##Phrase, No truncation,all of subfield field must match } else { $attr .= " \@attr 5=1 \@attr 4=6 " ; ## Word list, right truncated, anywhere - if ($sortby eq 'Relevance') { - $attr .= "\@attr 2=102 "; - } + if ( $sortby eq 'Relevance' ) { + $attr .= "\@attr 2=102 "; + } } - @$value[$i] =~ s/"/\\"/g; # Escape the double-quotes in the search value - $attr =$attr."\"".@$value[$i]."\""; - $q2 .=$attr; - $dosearch=1; + @$value[$i] =~ + s/"/\\"/g; # Escape the double-quotes in the search value + $attr = $attr . "\"" . @$value[$i] . "\""; + $q2 .= $attr; + $dosearch = 1; ++$attr_cnt; if ($QParser) { $qpquery .= " $tags->[$i]:\"$value->[$i]\""; } - }#if value + } #if value } ##Add how many queries generated if (defined $query && $query=~/\S+/){ -- 2.39.5