From 8c509cf33029b376b9e426ede788c44654876b75 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Wed, 23 Jul 2014 08:41:47 +0300 Subject: [PATCH] Bug 12630: Prioritizing "Hold starts on date" -holds causes all other holds to be prioritized as well! ------------------------- -- REPLICATE LIKE THIS -- ------------------------- 0. Enable AllowHoldDateInFuture-system preference! 1. Select a biblio with some holds. 2. Place a hold with the "Hold starts on date"-attribute set to future. 3. More the specific hold up on the priority queue. 4. Add another normal hold, observe how it is prioritized with the "Hold starts on date"-hold, leaving old holds to the prioritization queue tail. Unfair eh? Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 05ac7e0d4a1d4247df43f4a83ead509cfaffa04c) Signed-off-by: Lucas Gass --- C4/Reserves.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 9beae19d62..4de9181b30 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -224,11 +224,9 @@ sub AddReserve { $found = 'W'; } } - - if ( C4::Context->preference('AllowHoldDateInFuture') ) { - - # Make room in reserves for this before those of a later reserve date - $priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority ); + if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) { + # Make room in reserves for this before those of a later reserve date + $priority = _ShiftPriorityByDateAndPriority( $biblionumber, $priority ); } my $waitingdate; @@ -1962,12 +1960,12 @@ the sub accounts for that too. =cut sub _ShiftPriorityByDateAndPriority { - my ( $biblio, $resdate, $new_priority ) = @_; + my ( $biblio, $new_priority ) = @_; my $dbh = C4::Context->dbh; - my $query = "SELECT priority FROM reserves WHERE biblionumber = ? AND ( reservedate > ? OR priority > ? ) ORDER BY priority ASC LIMIT 1"; + my $query = "SELECT priority FROM reserves WHERE biblionumber = ? AND priority > ? ORDER BY priority ASC LIMIT 1"; my $sth = $dbh->prepare( $query ); - $sth->execute( $biblio, $resdate, $new_priority ); + $sth->execute( $biblio, $new_priority ); my $min_priority = $sth->fetchrow; # if no such matches are found, $new_priority remains as original value $new_priority = $min_priority if ( $min_priority ); -- 2.39.5