Bug 24602: Make get_onshelfholds_policy fallback to 0
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 6 Feb 2020 14:10:39 +0000 (11:10 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 10 Feb 2020 08:56:39 +0000 (08:56 +0000)
commitd31ee5980b2a52db6d1c60d9dd744f4584df3e40
tree68bd52da4488cd9182d6cc50585d5de69e5f24a4
parent661e598d7035fe74b25e2d7ceef338fba38aa18d
Bug 24602: Make get_onshelfholds_policy fallback to 0

The onshelfholds circulation rules values are more of an ENUM type (as
opposed to other rules with integers like max*qty). In the
quantities cases, it makes sense to have undef mean unlimited. In the
enum type it is clearer to just set a default value (0) as the code
already expects (Note: undef and 0 both eval to false so there's no
behaviour problem, but warnings or we get forced to check for
defined when the rule is used. It seems trivial to just make the
rule fallback to a chosen default value).

This patch makes it fallback to 0.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/CirculationRules.t \
           t/db_dependent/Reserves.t
=> FAIL: CirculationRules.t fails and Reserves.t prints a warning
2. Apply this patch
3. Repeat (1)
=> SUCCESS: Tests pass! No warning!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/CirculationRules.pm