[Koha-bugs] [Bug 16848] New: Wrong warning "Invalid date ... passed to output_pre" can be carped

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Jul 4 16:31:21 CEST 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16848

            Bug ID: 16848
           Summary: Wrong warning "Invalid date ... passed to output_pre"
                    can be carped
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: ASSIGNED
          Severity: normal
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: jonathan.druart at bugs.koha-community.org
          Reporter: jonathan.druart at bugs.koha-community.org
        QA Contact: testopia at bugs.koha-community.org

>From Koha::DateUtils::output_pref:

   $dt = eval { dt_from_string( $str ) } if $str;
   carp "Invalid date '$str' passed to output_pref\n" if $@;

This second line is wrong: if $str does not exist, the first line is not
evaluated and $@ could be filled with previous error.

To reproduce:

diff --git a/t/DateUtils.t b/t/DateUtils.t
index eede4a0..2dd6a9d 100755
--- a/t/DateUtils.t
+++ b/t/DateUtils.t
@@ -229,3 +229,5 @@ is( $output_for_invalid_date, undef, 'output_pref should
return undef if an inva
 warning_is { output_pref( { 'str' => $testdate_iso, dt => $dt, dateformat =>
'iso', dateonly => 1 } ) }
            { carped => 'output_pref should not be called with both dt and str
parameters' },
            'output_pref should carp if str and dt parameters are passed
together';
+
+output_pref();


Then:
  prove t/DateUtils.t
will display:
t/DateUtils.t .. 20/60 Use of uninitialized value $str in concatenation (.) or
string at Koha/DateUtils.pm line 217.
Invalid date '' passed to output_pref
 at t/DateUtils.t line 233.
t/DateUtils.t .. ok     
All tests successful.
Files=1, Tests=60,  2 wallclock secs ( 0.02 usr  0.00 sys +  1.40 cusr  0.00
csys =  1.42 CPU)
Result: PASS

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


More information about the Koha-bugs mailing list