From 8fdb91b6e318af90fefb64db9705dee9db17984e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 13 Jan 2022 12:10:30 -0300 Subject: [PATCH] Bug 29877: Make POST /holds handle maxreserves correctly The current implementation doesn't consider the following values for the syspref: undef and 0. The tests mistakenly didn't cover them. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => FAIL: Tests fail, obvious warnings about comparing undefined values too. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. You can try on Postman as well => SUCCESS: Behavior is correct! 6. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit b002a84a2c6e5ee59562620b62bb21cfc7f61a02) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit 19f3a58d4d57bc89017f22d3db640160142fe2dd) Signed-off-by: Victor Grousset/tuxayo --- Koha/REST/V1/Holds.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index bf6f6b3adc..0cfe9f42e8 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -167,7 +167,7 @@ sub add { ? C4::Reserves::CanItemBeReserved( $patron_id, $item_id ) : C4::Reserves::CanBookBeReserved( $patron_id, $biblio_id ); - if ( $patron->holds->count + 1 > C4::Context->preference('maxreserves') ) { + if ( C4::Context->preference('maxreserves') && $patron->holds->count + 1 > C4::Context->preference('maxreserves') ) { $can_place_hold->{status} = 'tooManyReserves'; } -- 2.39.5