Closed Bug 156680 Opened 21 years ago Closed 21 years ago

Undefined variable warning from createaccount.cgi

Categories

(Bugzilla :: User Accounts, defect)

2.16
Sun
Solaris
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.16

People

(Reporter: mike, Assigned: jouni)

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

I just upgraded my bugzilla from 2.14 to 2.16rc2 and got the following warning
from createaccount.cgi:

Use of uninitialized value in substitution (s///) at globals.pl line 1512 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.
    
    To help you figure out what was undefined, perl tells you what operation
    you used the undefined value in.  Note, however, that perl optimizes your
    program and the operation displayed in the warning may not necessarily
    appear literally in your program.  For example, "that $foo" is
    usually optimized into "that " . $foo, and the warning will refer to
    the concatenation (.) operator, even though there is no . in your
    program.
    
[Wed Jul 10 11:20:05 2002] createaccount.cgi: Use of uninitialized value in
substitution (s///) at globals.pl line 1512.
Use of uninitialized value in substitution (s///) at globals.pl line 1513 (#1)
[Wed Jul 10 11:20:05 2002] createaccount.cgi: Use of uninitialized value in
substitution (s///) at globals.pl line 1513.

I was able to workaround the bug by modifying the trim method in globals.pl to
check for an undefined value like so: 

# Trim whitespace from front and back.

sub trim {
    my ($str) = @_;
    if(defined $str)
    {
        $str =~ s/^\s+//g;
        $str =~ s/\s+$//g;
    }
    return $str;
}

and things are working well now. My bugzilla is running on solaris 2.6, perl
5.6.1, mysql 3.23.45, Netscape Enterprise Server 3.6
Updated platform and os to relfect the server, not my workstation
OS: MacOS X → Solaris
Hardware: Macintosh → Sun
Thanks for the nice bug report. The fix you mentioned works too, but it would
prevent us from seeing other problems with undef'd values -> I'd rather patch
createaccount.

Actually, I've just done it. ;) Taking & adding keywords; this is a regression.
Assignee: myk → jouni
Keywords: patch, regression, review
Target Milestone: --- → Bugzilla 2.16
Attached patch v1 (obsolete) — Splinter Review
Summary: Undefined value in globals.pl → Undefined variable warning from createaccount.cgi
Attached patch v2: fixesSplinter Review
re discussion w/ bbaetz on IRC, removing the or condition from the assignment,
since a valid form field cannot be undef at the point $realname is being
assigned now...
Attachment #90940 - Attachment is obsolete: true
Comment on attachment 90947 [details] [diff] [review]
v2: fixes

r=bbaetz x2
Attachment #90947 - Flags: review+
Checked into trunk and branch:

Checking in createaccount.cgi;
/cvsroot/mozilla/webtools/bugzilla/createaccount.cgi,v  <--  createaccount.cgi
new revision: 1.23; previous revision: 1.22
done

Checking in createaccount.cgi;
/cvsroot/mozilla/webtools/bugzilla/createaccount.cgi,v  <--  createaccount.cgi
new revision: 1.21.2.2; previous revision: 1.21.2.1
done
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.