Bug 7413: (follow-up) validate norenewalbefore values better
authorGalen Charlton <gmc@esilibrary.com>
Tue, 8 Apr 2014 22:46:28 +0000 (22:46 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 8 Apr 2014 22:46:28 +0000 (22:46 +0000)
This patch ensures both both '0' and strings consisting of zero
or more blanks are recognized by the circ rules editor as specifying
clearing the "no renewal before" value.  Concretely, this fixes
warnings of the following form when clearing this field:

    Argument "" isn't numeric in numeric eq (==)

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
admin/smart-rules.pl

index 6721ea4..456e738 100755 (executable)
@@ -115,7 +115,7 @@ elsif ($op eq 'add') {
     my $renewalsallowed  = $input->param('renewalsallowed');
     my $renewalperiod    = $input->param('renewalperiod');
     my $norenewalbefore  = $input->param('norenewalbefore');
-    $norenewalbefore = undef if $norenewalbefore == 0;
+    $norenewalbefore = undef if $norenewalbefore eq '0' or $norenewalbefore =~ /^\s*$/;
     my $reservesallowed  = $input->param('reservesallowed');
     $maxissueqty =~ s/\s//g;
     $maxissueqty = undef if $maxissueqty !~ /^\d+/;