fix "amatch: $_ is undefined: what are you matching" error when there are no companie...
authorivan <ivan>
Thu, 12 Oct 2006 09:42:27 +0000 (09:42 +0000)
committerivan <ivan>
Thu, 12 Oct 2006 09:42:27 +0000 (09:42 +0000)
FS/FS/cust_main.pm

index 95ed7de..3942acf 100644 (file)
@@ -3969,12 +3969,12 @@ sub fuzzy_search {
 
   check_and_rebuild_fuzzyfiles();
   foreach my $field ( keys %$fuzzy ) {
+
+    my $all = $self->all_X($field);
+    next unless scalar(@$all);
+
     my %match = ();
-    $match{$_}=1 foreach ( amatch( $fuzzy->{$field},
-                                   ['i'],
-                                   @{ $self->all_X($field) }
-                                 )
-                         );
+    $match{$_}=1 foreach ( amatch( $fuzzy->{$field}, ['i'], @$all ) );
 
     my @fcust = ();
     foreach ( keys %match ) {