Do not declare variables within (bogus) conditionals
authorColin Campbell <colin.campbell@ptfs-europe.com>
Sun, 9 May 2010 14:58:52 +0000 (15:58 +0100)
committerGalen Charlton <gmcharlt@gmail.com>
Tue, 11 May 2010 10:07:19 +0000 (06:07 -0400)
if $index is unnecessary as we have made this true 5 lines above
variables should not be declared in conditionals if used outside of them
set $struct_attr to a sensible default to avoid generating warnings
in this assigment and elsewhere

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
C4/Search.pm

index 30d8b4f..229ee40 100644 (file)
@@ -1123,14 +1123,14 @@ sub buildQuery {
                 }
 
                 # Set default structure attribute (word list)
-                my $struct_attr;
+                my $struct_attr = q{};
                 unless ( $indexes_set || !$index || $index =~ /(st-|phr|ext|wrdl)/ ) {
                     $struct_attr = ",wrdl";
                 }
 
                 # Some helpful index variants
-                my $index_plus       = $index . $struct_attr . ":" if $index;
-                my $index_plus_comma = $index . $struct_attr . "," if $index;
+                my $index_plus       = $index . $struct_attr . ':';
+                my $index_plus_comma = $index . $struct_attr . ',';
 
                 # Remove Stopwords
                 if ($remove_stopwords) {