Bug 24669: Improve numeric input handling in smart-rules.pl
authorJoonas Kylmälä <joonas.kylmala@helsinki.fi>
Mon, 17 Feb 2020 09:48:22 +0000 (09:48 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 19 Feb 2020 11:28:16 +0000 (11:28 +0000)
commit4a9330df408bd7bfd6bfafbedeeb1cb9ce858d9a
tree4a0c103b332fc11ddf82858265c1c288c48102a7
parentf3d8a3b91aef7debb66d064d8150843ed448b1fe
Bug 24669: Improve numeric input handling in smart-rules.pl

This removes code duplication by introducing a new subroutine
strip_non_numeric() that removes whitespace and makes the rule value
'' if it is a string value instead of a digit. The call to
strip_non_numeric() is now added also to all the rules it is needed
in.

To test:
1. Write some string like "test" to rules:
  - Current checkouts allowed
  - Current on-site checkouts allowed
  - Holds allowed (total)
  - Holds allowed (daily)
  - Holds per record (count)
  - Holds per record (count) – can be found in default policy
2. Save rules
3. Apply patch
4. Edit the rule line where you just typed all those strings and save
5. Notice how the values are now empty strings (some say "unlimited" but
   if you go check from DB it should show empty value there)

Sponsored-by: The National Library of Finland
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
admin/smart-rules.pl