Item11363: "Use of uninitialized value in substitution iterator" warning

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: DatabasePlugin
Branches: trunk
Reported By: FlorianSchlichting
Waiting For: FlorianSchlichting
Last Change By: FlorianSchlichting
"NULL" is a perfectly valid value for a database field, in fact it is often seen as the preferred database representation for the empty string.

However, NULL is represented as an undef value by DBI, which results in a warning when used in a substitution or other string interpolation. This is easily guarded against by the following patch:

--- a/lib/Foswiki/Plugins/DatabasePlugin/DATABASE_SQL.pm
+++ b/lib/Foswiki/Plugins/DatabasePlugin/DATABASE_SQL.pm
@@ -22,6 +22,7 @@ sub handle {

             # reverse sort so we handle longer keys first
             foreach my $k ( reverse sort keys %$res ) {
+                $res->{$k} = '' unless defined $res->{$k};
                 $row =~ s/\$$k/$res->{$k}/g;
             }
             $result .= $row . $separator;

-- FlorianSchlichting - 16 Dec 2011

 

ItemTemplate edit

Summary "Use of uninitialized value in substitution iterator" warning
ReportedBy FlorianSchlichting
Codebase 1.1.4, trunk
SVN Range
AppliesTo Extension
Component DatabasePlugin
Priority Normal
CurrentState Closed
WaitingFor FlorianSchlichting
Checkins DatabasePlugin:5014d1a1f1d5
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches trunk
trunkCheckins DatabasePlugin:5014d1a1f1d5
Release01x01Checkins
Topic revision: r3 - 19 Dec 2011, FlorianSchlichting
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy