From 4942b60ce331314e3ec334e4c306d719409205ef Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 4 Jun 2014 10:48:02 -0400 Subject: [PATCH] Bug 5144 [2] - Duplicate holds allowed if patron clicks back button after placing hold Koha is currently not engineered to handle multiple holds per record. Until such time that is does, we should not allow them to be created. Test Plan: 1) Apply the first patch in this series 2) Run t/db_dependent/Reserves.t 3) Note the failure of test 36 4) Apply the second patch in this series 5) Re-run Reserves.t 6) Note the success of test 36 --- C4/Reserves.pm | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d399ee0..b342c61 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -40,6 +40,7 @@ use C4::Dates qw( format_date_in_iso ); use Koha::DateUtils; use List::MoreUtils qw( firstidx ); +use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -149,6 +150,17 @@ sub AddReserve { $constraint, $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found ) = @_; + + my ($count) = C4::Context->dbh->selectrow_array( + 'SELECT COUNT(*) FROM reserves WHERE biblionumber = ? AND borrowernumber = ?', + undef, + ( $biblionumber, $borrowernumber ) + ); + if ( $count > 0 ) { + carp("AddReserve: borrower $borrowernumber already has $count holds for biblionumber $biblionumber"); + return; + } + my $fee = GetReserveFee($borrowernumber, $biblionumber, $constraint, $bibitems ); -- 1.7.2.5