From 0c560baa521a1b8166471df66f5061e85b4e9ad9 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 10 Jan 2017 13:20:02 +0100 Subject: [PATCH] Bug 11999: Remove 'alreadyReserved' check in CanBookBeReserved Since bug 14695 it is possible to reserve more than one item per biblio Also fix bad use of $item --- C4/Reserves.pm | 9 +-------- t/db_dependent/Holds.t | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 01fdc96d4b..770362fc99 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -291,16 +291,9 @@ See CanItemBeReserved() for possible return values. sub CanBookBeReserved{ my ($borrowernumber, $biblionumber) = @_; - # Check if borrower already has reserved the same biblio. + # Check if borrower has reached the maximum number of holds allowed my $patron = Koha::Patrons->find($borrowernumber); my $holds = $patron->holds; - while (my $hold = $holds->next) { - if ($hold->biblionumber == $biblionumber) { - return 'alreadyReserved'; - } - } - - # Check if borrower has reached the maximum number of holds allowed my $maxreserves = C4::Context->preference('maxreserves'); if ($maxreserves && $holds->count >= $maxreserves) { return 'tooManyReserves'; diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index ce7a01f686..9e54ed55dd 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -403,7 +403,7 @@ is( is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'OK'); C4::Context->set_preference('maxreserves', 1); -ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); +is(CanBookBeReserved($borrowernumbers[0], $biblionumber), 'tooManyReserves'); C4::Context->set_preference('maxreserves', 0); t::lib::Mocks::mock_preference('IndependentBranches', 1); -- 2.11.0