From 58fe4146b660df8d52eeaba1f25548203f28d6ac 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 --- C4/Reserves.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9eb9a35fed..a5e41b8c91 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.30.2