From 64d852120feb52cef0a18744410fc98598c1fdfe Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 17 Jun 2020 10:07:46 -0400 Subject: [PATCH] Bug 25783: Holds Queue treating item-level holds as bib-level I discovered two issues. First, the holds queue builder does not honor the new item_level_hold flag. Instead, it only item_level_request if in the loop dealing with item level holds. This is incorrect. Item level holds may be trapped in the local holds priority loop as well. It's trivial to just pass though the correct item/biblio level hold flag. In addition, in bug 23934 I removed the line of code that prevented local holds priority from working for item level holds. This change itself was good and correct. However, the code in that loop does not check to ensure the item matches the requested item! That means it can match an item level hold with the wrong item! I do not know how to write a reproducable test plan for these issues. --- C4/HoldsQueue.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 5f2c2c556c..339156a5eb 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -277,7 +277,7 @@ sub GetPendingHoldRequestsForBib { my $dbh = C4::Context->dbh; my $request_query = "SELECT biblionumber, borrowernumber, itemnumber, priority, reserves.branchcode, - reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype + reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype, item_level_hold FROM reserves JOIN borrowers USING (borrowernumber) WHERE biblionumber = ? @@ -409,6 +409,8 @@ sub MapItemsToHoldRequests { || ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); + next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; + next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); my $local_holds_priority_item_branchcode = @@ -436,7 +438,7 @@ sub MapItemsToHoldRequests { holdingbranch => $item->{holdingbranch}, pickup_branch => $request->{branchcode} || $request->{borrowerbranch}, - item_level => 0, + item_level => $request->{item_level_hold}, reservedate => $request->{reservedate}, reservenotes => $request->{reservenotes}, }; @@ -475,7 +477,7 @@ sub MapItemsToHoldRequests { biblionumber => $request->{biblionumber}, holdingbranch => $items_by_itemnumber{ $request->{itemnumber} }->{holdingbranch}, pickup_branch => $request->{branchcode} || $request->{borrowerbranch}, - item_level => 1, + item_level => $request->{item_level_hold}, reservedate => $request->{reservedate}, reservenotes => $request->{reservenotes}, }; @@ -650,7 +652,7 @@ sub MapItemsToHoldRequests { biblionumber => $request->{biblionumber}, holdingbranch => $holdingbranch, pickup_branch => $pickup_branch, - item_level => 0, + item_level => $request->{item_level_hold}, reservedate => $request->{reservedate}, reservenotes => $request->{reservenotes}, }; -- 2.24.1 (Apple Git-126)