[Koha-bugs] [Bug 13075] Use of uninitialized value while proving db_dependent/Holds.t

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Oct 14 20:24:14 CEST 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13075

--- Comment #3 from M. Tompsett <mtompset at hotmail.com> ---
(In reply to Chris Cormack from comment #2)
> > +    return $string if !defined($string);
> 
> could we write this better as return unless $string;

return unless defined($string), perhaps. String could be 0 or q{}.


> Or should we be actually croaking if we call this without actually passing
> it anything to normalize, instead of silently hiding that we are calling it
> wrong?

I did not determine why undef was passed, but perhaps further investigation as
to why undef is passed would clarify if croak is necessary. Seeing as no other
warnings were generated with this solution, I don't think it is.

It should be noted that NFC(undef) and NFD(undef) both return the empty string,
so perhaps another solution (possibly better?) is: $string //= q{};

Though, I think it is rather ugly to mangle an undef into an empty string to
avoid warnings. That is why I choose this current solution.

I'll rework this to the 'unless' idea that you suggested, Chris. -- time passes
-- While doing this, I discovered that a NormalizeString call is pushed into an
array, and so the context is a list, so return unless defined($string);
triggers warnings while trying to run prove -v t/db_dependent/Holds.t for
testing. Inserting an explicit $string (return $string unless defined($string))
forces a scalar return, and prevents warnings.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list