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 <tomascohen@theke.io>

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit b002a84a2c)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
(cherry picked from commit 19f3a58d4d)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Tomas Cohen Arazi 2022-01-13 12:10:30 -03:00 committed by Victor Grousset/tuxayo
parent 2fa43197c1
commit 8fdb91b6e3
1 changed files with 1 additions and 1 deletions

View File

@ -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';
}