@@ -, +, @@ CanBookBeReserved --- C4/Reserves.pm | 9 +-------- t/db_dependent/Holds.t | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) --- a/C4/Reserves.pm +++ a/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'; --- a/t/db_dependent/Holds.t +++ a/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); --