From e221bc52a06b9e46cdb502119411693bfa5affe9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 11 Feb 2022 19:56:42 +0000 Subject: [PATCH] Bug 30085: Move IndependentBranches check sooner This doesn't rely on the other statuses, and requires only cached preference check, so lets allow the possibiliy of an early exit Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers --- C4/Reserves.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 7493a6eab8..6e86857db8 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -385,6 +385,16 @@ sub CanItemBeReserved { my $ruleitemtype; # itemtype of the matching issuing rule my $allowedreserves = 0; # Total number of holds allowed across all records, default to none + # We check item branch if IndependentBranches is ON + # and canreservefromotherbranches is OFF + if ( C4::Context->preference('IndependentBranches') + and !C4::Context->preference('canreservefromotherbranches') ) + { + if ( $item->homebranch ne $patron->branchcode ) { + return { status => 'cannotReserveFromOtherBranches' }; + } + } + # we retrieve borrowers and items informations # # item->{itype} will come for biblioitems if necessery my $biblio = $item->biblio; @@ -554,16 +564,6 @@ sub CanItemBeReserved { } } - # If reservecount is ok, we check item branch if IndependentBranches is ON - # and canreservefromotherbranches is OFF - if ( C4::Context->preference('IndependentBranches') - and !C4::Context->preference('canreservefromotherbranches') ) - { - if ( $item->homebranch ne $patron->branchcode ) { - return { status => 'cannotReserveFromOtherBranches' }; - } - } - if ($pickup_branchcode) { my $destination = Koha::Libraries->find({ branchcode => $pickup_branchcode, -- 2.39.5