Bug 11182: (QA followup) fix warning if itemBarcodeFallbackSearch set
authorTomas Cohen Arazi <tomascohen@gmail.com>
Fri, 31 Jan 2014 16:00:18 +0000 (13:00 -0300)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 29 Apr 2014 18:02:21 +0000 (18:02 +0000)
To reproduce:
- On top of the previous patches, if you enable the
  itemBarcodeFallbackSearch syspref and do a search for a term that
  returns at least one result, there will be warnings for each result
  without items attached.

To test:

- In the checkout form enter a term that should return results (some of
  them without items attached)
=> There are warnings on the logs regarding a split of undef variable
- Apply the patch
- Repeat the first step
=> No warnings

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
circ/circulation.pl

index 3459df5..91851d2 100755 (executable)
@@ -315,10 +315,12 @@ if ($barcode) {
                     C4::Search::new_record_from_zebra('biblioserver',$hit) );
 
                 # offer all barcodes individually
-                foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
-                    my %chosen_single = %{$chosen};
-                    $chosen_single{barcode} = $barcode;
-                    push( @options, \%chosen_single );
+                if ( $chosen->{barcode} ) {
+                    foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
+                        my %chosen_single = %{$chosen};
+                        $chosen_single{barcode} = $barcode;
+                        push( @options, \%chosen_single );
+                    }
                 }
             }
             $template->param( options => \@options );