Adding some checking in facet branches
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 27 Mar 2009 16:21:35 +0000 (17:21 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Mon, 13 Jul 2009 10:42:37 +0000 (12:42 +0200)
When using search via commandline scripts, branch facets are sometimes
failing badly.
Not a HASH reference at
C4/Search.pm line 557,
This patch prevents this

C4/Search.pm

index 41119a3..da70ddf 100644 (file)
@@ -531,8 +531,17 @@ sub getRecords {
 
                             # if it's a branch, label by the name, not the code,
                             if ( $link_value =~ /branch/ ) {
-                                $facet_label_value =
-                                  $branches->{$one_facet}->{'branchname'};
+                                                               if (defined $branches 
+                                                                       && ref($branches) eq "HASH" 
+                                                                       && defined $branches->{$one_facet} 
+                                                                       && ref ($branches->{$one_facet}) eq "HASH")
+                                                               {
+                                       $facet_label_value =
+                                               $branches->{$one_facet}->{'branchname'};
+                                                               }
+                                                               else {
+                                                                       $facet_label_value = "*";
+                                                               }
                             }
 
                 # but we're down with the whole label being in the link's title.