[Koha-patches] [PATCH] bug 2860: allow setting of a syspref value to '0'

Galen Charlton galen.charlton at liblime.com
Wed Dec 17 16:53:39 CET 2008


Fixed invalid test for the existence of CGI parameter; if it
is possible that the value of a parameter can be 0, it is
not sufficient to test like this:

if ($input->param('foo')) { ...

since the test will fail for *any* value that evaluates
to Perl false.
---
 admin/systempreferences.pl |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index e084a49..42bdcbc 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -594,12 +594,19 @@ if ($op eq 'add_form') {
     my $value;
     # handle multiple value strings (separated by ',')
     my $params = $input->Vars;
-    my @values = ();
-    @values = split("\0",$params->{'value'}) if $params->{'value'};
-    for my $vl (@values) {
-        $value .= "$vl,";
+    if (defined $params->{'value'}) {
+        my @values = ();
+        @values = split("\0",$params->{'value'}) if defined($params->{'value'});
+        if (@values) {
+            $value = "";
+            for my $vl (@values) {
+                $value .= "$vl,";
+            }
+            $value =~ s/,$//;
+        } else {
+            $value = $params->{'value'};
+        }
     }
-    $value =~ s/,$//;
     if ($sth->rows) {
         unless (C4::Context->config('demo')) {
             my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
-- 
1.5.5.GIT




More information about the Koha-patches mailing list