[Koha-patches] [PATCH] bug 2527: avoid targeting of items on hold shelf

Galen Charlton galen.charlton at liblime.com
Fri Aug 15 23:38:22 CEST 2008


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.
---
 misc/cronjobs/holds/build_holds_queue.pl |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl
index ae075b7..26a2dba 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 ]; 
-- 
1.5.5.GIT




More information about the Koha-patches mailing list