Bugzilla – Attachment 136656 Details for
Bug 30196
Odd number of elements warning caused by dt_from_string
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30196: Odd number of elements warning caused by dt_from_string
Bug-30196-Odd-number-of-elements-warning-caused-by.patch (text/plain), 1.56 KB, created by
Shi Yao Wang
on 2022-06-27 17:33:40 UTC
(
hide
)
Description:
Bug 30196: Odd number of elements warning caused by dt_from_string
Filename:
MIME Type:
Creator:
Shi Yao Wang
Created:
2022-06-27 17:33:40 UTC
Size:
1.56 KB
patch
obsolete
>From 80b7104e58952b2c08cddee0e365b6a92dde3662 Mon Sep 17 00:00:00 2001 >From: Blou <blou@inlibro.com> >Date: Mon, 28 Feb 2022 12:12:38 -0500 >Subject: [PATCH] Bug 30196: Odd number of elements warning caused by > dt_from_string > >Koha/DateUtils' dt_from_string is a sub expected to return a scalar, but >does not in all case. > >In one instance, tt simply return... nothing, which cause one common call >output_pref( { dt => dt_from_string( $serinfo->{$d} ), dateonly => 1 } ); >to output a warning. > >Simply returning undef instead will solve the issue. > >Test plan: >1- Have a terminal tail intranet error logs >2- In the code, go to about.pl and change the only dt_from_string() to dt_from_string('0000-00-00') >3- Go to About Koha >4- Notice the logs output is: "Odd number of elements in anonymous hash at ..." and error 500 on the page. >5- Apply the patch >6- Redo step 3 and notice the previous log output is not there and the page loads >7- run `prove t/DateUtils.t` and all tests should pass >--- > Koha/DateUtils.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index 2ee889aac5..7d3be8d3f6 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -58,7 +58,7 @@ to the system preferences. If the date string is empty DateTime->now is returned > sub dt_from_string { > my ( $date_string, $date_format, $tz ) = @_; > >- return if $date_string and $date_string =~ m|^0000-0|; >+ return undef if $date_string and $date_string =~ m|^0000-0|; > > my $do_fallback = defined($date_format) ? 0 : 1; > my $server_tz = C4::Context->tz; >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30196
:
131170
| 136656