From 9bb70614adb575b723f8ed916376d5972eba8b81 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 21 Apr 2022 13:21:12 +0000 Subject: [PATCH] Bug 30580: Don't use GetTransfers in GetItemsAvailableToFillHoldRequestsForBib This patch simply moves the check for transfers into the initial query To test: 1 - Place some holds that show in the holds queue 2 - Add a manual transfer to one item 3 - Confirm it no longer hsows in the queue 4 - Apply patch 5 - Confirm item still does not appear in the queue --- C4/HoldsQueue.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index b7cf0c7027..dc41d49ab0 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -322,7 +322,8 @@ sub GetItemsAvailableToFillHoldRequestsForBib { my $dbh = C4::Context->dbh; my $items_query = "SELECT itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype - FROM items "; + FROM items + LEFT JOIN branchtransfers USING (itemnumber)"; if (C4::Context->preference('item-level_itypes')) { $items_query .= "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) "; @@ -344,7 +345,9 @@ sub GetItemsAvailableToFillHoldRequestsForBib { AND itemnumber IS NOT NULL AND (found IS NOT NULL OR priority = 0) ) - AND items.biblionumber = ?"; + AND items.biblionumber = ? + AND branchtransfers.datearrived IS NULL + AND branchtransfers.datecancelled IS NULL"; my @params = ($biblionumber, $biblionumber); if ($branches_to_use && @$branches_to_use) { @@ -354,13 +357,12 @@ sub GetItemsAvailableToFillHoldRequestsForBib { my $sth = $dbh->prepare($items_query); $sth->execute(@params); - my $itm = $sth->fetchall_arrayref({}); - my @items = grep { ! scalar GetTransfers($_->{itemnumber}) } @$itm; + my $items = $sth->fetchall_arrayref({}); return [ grep { my $rule = GetBranchItemRule($_->{homebranch}, $_->{itype}); $_->{holdallowed} = $rule->{holdallowed}; $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy}; - } @items ]; + } @$items ]; } =head2 _checkHoldPolicy -- 2.30.2