Summary: | Wrong warning "Invalid date ... passed to output_pref" can be carped | ||
---|---|---|---|
Product: | Koha | Reporter: | Jonathan Druart <jonathan.druart> |
Component: | Architecture, internals, and plumbing | Assignee: | Jonathan Druart <jonathan.druart> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | normal | ||
Priority: | P5 - low | CC: | f.demians, julian.maurice, kyle, srdjan |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: |
Bug 16848: Prevent invalid warning to be carped from output_pref
[SIGNED-OFF] Bug 16848: Prevent invalid warning to be carped from output_pref [PASSED QA] Bug 16848: Prevent invalid warning to be carped from output_pref |
Description
Jonathan Druart
2016-07-04 14:31:21 UTC
Created attachment 53090 [details] [review] Bug 16848: Prevent invalid warning to be carped from output_pref 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: 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 Test plan: Without this patch, you should not see the carp Created attachment 53120 [details] [review] [SIGNED-OFF] Bug 16848: Prevent invalid warning to be carped from output_pref 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: 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 Test plan: Without this patch, you should not see the carp Signed-off-by: Srdjan <srdjan@catalyst.net.nz> I took liberty of adding local $@ (In reply to Srdjan Jankovic from comment #3) > I took liberty of adding local $@ Are you sure it is useful? Probably not that much, but I have a habit of doing that, I believe it is a good practice. Jonathan, Srdjan, is this ready for QA? I think so, unless Jonathan fiercely objects, in which case I'll remove the line that I've added. (In reply to Srdjan Jankovic from comment #7) > I think so, unless Jonathan fiercely objects, in which case I'll remove the > line that I've added. It should not hurt, so I am ok with it. Created attachment 54121 [details] [review] [PASSED QA] Bug 16848: Prevent invalid warning to be carped from output_pref 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: 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 Test plan: Without this patch, you should not see the carp Signed-off-by: Srdjan <srdjan@catalyst.net.nz> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Pushed to master for 16.11, thanks Jonathan! Pushed in 16.05. Will be in 16.05.03. Pushed in 16.05. Will be in 16.05.03. Pushed to 3.22.x, will be in 3.22.10 |