From c53ee51fc42d81aa1690d97476393aa4784a1c55 Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Wed, 24 Jul 2019 11:33:48 +0000
Subject: [PATCH] Bug 22806: (follow-up) CanBookBeReserved and
 CanItemBeReserved must check AllowHoldsOnPatronsPossessions

As CanBookBeReserved() was failing as $patron and and $biblio were not
instantiated I fixed that up.

Test plan :
1 - set AllowHoldsOnPatronsPossessions to "Don't Allow"
2 - Checkout an item to a borrower
3 - Try to reserve an item using ILS-DI WebService -> Will work without complaining.
4 - Cancel the hold and apply patch
5 - Repeat 3 -> Should not place hold and show error "NotHoldable"

Sponsored-By: Catalyst IT
Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
---
 C4/Reserves.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index bbc27a287f..317a4b10fa 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -276,7 +276,7 @@ sub CanBookBeReserved{
 
     # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set)
     if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
-        && C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) {
+        && C4::Circulation::CheckIfIssuedToPatron( $borrowernumber, $biblionumber ) ) {
         return { status =>'itemAlreadyOnLoan' };
     }
 
-- 
2.20.1