From 8588c7d79eae2c4c0f1aa071d3ff4d754c14904b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 15 Aug 2008 16:38:22 -0500 Subject: [PATCH] bug 2527: avoid targeting of items on hold shelf SQL fix to properly ensure that if an item is on the hold shelf, it will not be used for request targeting, which applies only to items that are not already on the hold shelf. Prior to this fix, when checking out an item on the hold shelf that fills patron A's hold request, it was possible for that request to not be marked as filled if another patron had an item-level request on the item; the second patron's request was incorrectly targeted by that item. Signed-off-by: Galen Charlton --- misc/cronjobs/holds/build_holds_queue.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index ae075b7fa6..26a2dbad45 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -162,18 +162,22 @@ sub GetItemsAvailableToFillHoldRequestsForBib { $items_query .= "JOIN biblioitems USING (biblioitemnumber) LEFT JOIN itemtypes USING (itemtype) "; } - $items_query .= "LEFT JOIN reserves USING (itemnumber) - WHERE items.notforloan = 0 + $items_query .= "WHERE items.notforloan = 0 AND holdingbranch IS NOT NULL AND itemlost = 0 AND wthdrawn = 0 AND items.onloan IS NULL AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0) - AND (priority IS NULL OR priority > 0) - AND found IS NULL + AND itemnumber NOT IN ( + SELECT itemnumber + FROM reserves + WHERE biblionumber = ? + AND itemnumber IS NOT NULL + AND (found IS NOT NULL OR priority = 0) + ) AND biblionumber = ?"; my $sth = $dbh->prepare($items_query); - $sth->execute($biblionumber); + $sth->execute($biblionumber, $biblionumber); my $items = $sth->fetchall_arrayref({}); return [ grep { my @transfers = GetTransfers($_->{itemnumber}); $#transfers == -1; } @$items ]; -- 2.39.2