Bug 12861 : Noisy warn in the error logs
authorChris Cormack <chrisc@catalyst.net.nz>
Tue, 2 Sep 2014 21:49:41 +0000 (09:49 +1200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 21 Jan 2015 13:47:41 +0000 (10:47 -0300)
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 <chrisc@catalyst.net.nz>

Reformatted to fix error M Tompsett spotted

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Instead of 10 warnings, I now have only 4 warnings.
We're going in the right direction.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

C4/AuthoritiesMarc.pm

index 911532c..a779cbc 100644 (file)
@@ -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+/){