From 223d1fa6e873a94c8960688e5031c34828551f1d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 23 Aug 2009 09:19:49 -0400 Subject: [PATCH] bug 3409 follow: fix crash if holdingbranch is undef Make _GetCircControlBranch() default to the item's home library in the case where it otherwise would have returned the item's holding library but that field is null. Signed-off-by: Galen Charlton --- C4/Circulation.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 371dad9038..5930bed56b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1791,7 +1791,7 @@ C<$borrower> is a hashref to borrower. Only {branchcode} is used. =cut sub _GetCircControlBranch { - my ($iteminfos, $borrower) = @_; + my ($item, $borrower) = @_; my $circcontrol = C4::Context->preference('CircControl'); my $branch; @@ -1801,7 +1801,12 @@ sub _GetCircControlBranch { $branch=$borrower->{branchcode}; } else { my $branchfield = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch'; - $branch = $iteminfos->{$branchfield}; + $branch = $item->{$branchfield}; + # default to item home branch if holdingbranch is used + # and is not defined + if (!defined($branch) && $branchfield eq 'holdingbranch') { + $branch = $item->{homebranch}; + } } return $branch; } -- 2.39.2