From 434e1549ce85a06876be644dec0301dcea683857 Mon Sep 17 00:00:00 2001 From: Blou 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. --- Koha/DateUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 58fec0bef9..6413f37305 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -57,7 +57,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