minor fixes for SuperCat in the face of 0 holdings
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Jul 2006 07:33:29 +0000 (07:33 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Jul 2006 07:33:29 +0000 (07:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5029 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm

index f3e33df..9b0cfba 100644 (file)
@@ -191,6 +191,8 @@ sub tree_walker {
        my $field = shift;
        my $filter = shift;
 
+       return unless ($tree && ref($tree->$field));
+
        my @things = $filter->($tree);
        for my $v ( @{$tree->$field} ){
                push @things, $filter->($v);
@@ -235,7 +237,7 @@ sub cn_browse {
                }
        )->gather(1);
 
-       my @ou_ids = tree_walker($orgs, 'children', sub {shift->id});
+       my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
 
        $logger->debug("Searching for CNs at orgs [".join(',',@ou_ids)."], based on $ou");
 
@@ -340,7 +342,7 @@ sub new_record_holdings {
                }
        )->gather(1);
 
-       my @ou_ids = tree_walker($orgs, 'children', sub {shift->id});
+       my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
 
        $logger->debug("Searching for holdings at orgs [".join(',',@ou_ids)."], based on $ou");