From f8ebd79cc9dcaa5ded6440fc68309590f6de4420 Mon Sep 17 00:00:00 2001
From: Blou <philippe.blouin@inlibro.com>
Date: Thu, 17 Sep 2015 11:33:38 -0400
Subject: [PATCH] Bug 14846 - Items with no holdingbranch causes svc/holds to
 crash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When trying to display the holds for a user, if an item has no
holdingbranch, it causes the svc/holds service to crash and the display
to freeze.

Tentative steps to reproduce on any DB:
1) put 1 or more items on hold for a given user.
2) go into the database and set the item.holdingbranch to NULL
3) In the user's page, in checkouts (circulation.pl), click the tab that
   should be written 1 Hold(s)
4) It will be "Processing" indefinitely.

The cause is the svc/holds code that crashes.  The fix will validate
that there's an holdingbranch before proceding with the code.

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
---
 svc/holds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/svc/holds b/svc/holds
index 10d9205..9c90f8c 100755
--- a/svc/holds
+++ b/svc/holds
@@ -129,7 +129,7 @@ while ( my $h = $holds_rs->next() ) {
             $hold->{date_sent} = output_pref( dt_from_string($transferred_when) );
             $hold->{from_branch} = GetBranchName($transferred_from);
         }
-        elsif ( $item->holding_branch()->branchcode() ne
+        elsif ( $item->holding_branch() && $item->holding_branch()->branchcode() ne
             $h->branch()->branchcode() )
         {
             $hold->{not_transferred}    = 1;
-- 
2.6.2