From 20db4399cc768959eff4f7143ec448bd8a2f86be Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 22 May 2023 16:21:22 +0000 Subject: [PATCH] Bug 33795: Holds Queue builder should do cheap checks before expensive checks The holds queue builder runs many checks in a somewhat arbitrary order. We should order those checks such that the most expensive checks are at the end and can be avoided if a faster check fails. Test Plan: 1) prove t/db_dependent/HoldsQueue.t 2) Apply this patch 3) prove t/db_dependent/HoldsQueue.t 4) Tests still pass! Signed-off-by: Sam Lau --- C4/HoldsQueue.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 50feb8da6f..0dde1c5b0c 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -596,10 +596,6 @@ sub MapItemsToHoldRequests { my $holding_branch_items = $items_by_branch{$holdingbranch}; foreach my $item (@$holding_branch_items) { - next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); - - # Don't fill item level holds that contravene the hold pickup policy at this time - next unless _checkHoldPolicy($item, $request); # If hold itemtype is set, item's itemtype must match next unless ( !$request->{itemtype} @@ -612,6 +608,12 @@ sub MapItemsToHoldRequests { && $item->{_object}->item_group->id eq $request->{item_group_id} ) ); + # Don't fill a hold with a non-transferrable item + next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); + + # Don't fill item level holds that contravene the hold pickup policy at this time + next unless _checkHoldPolicy($item, $request); + $itemnumber = $item->{itemnumber}; last; } -- 2.30.2