From 1cf3443b6cae95acd5ac985cd9242d0e0d4790e2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 3 May 2016 12:57:13 +0000 Subject: [PATCH] Bug 16430 - Mainpage.pl dies if library is not set On a fresh install of Koha, logging in I was met with: Invalid dateformat parameter () at /home/vagrant/kohaclone/Koha/DateUtils.pm line 112. It appears that if the library is not set, you get this message on mainpage.pl. Needless to say, this adds difficulty in setting up a fresh install of Koha! Test Plan: 1) Check out master, start with a fresh empty database 2) Go through the installer, install all default data, log in with the db user for the first time 3) Note the error 4) Apply this patch 5) Refresh the page, the error should be gone --- C4/NewsChannels.pm | 3 ++- Koha/DateUtils.pm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index cbcc702..9b7c226 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -190,6 +190,7 @@ sub get_opac_news { sub GetNewsToDisplay { my ($lang,$branch) = @_; + my $dbh = C4::Context->dbh; # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate my $query = q{ @@ -216,7 +217,7 @@ sub GetNewsToDisplay { $sth->execute($lang,$branch); my @results; while ( my $row = $sth->fetchrow_hashref ){ - $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate} ), dateonly => 1 }); + $row->{newdate} = output_pref({ dt => dt_from_string( $row->{newdate}, 'iso' ), dateonly => 1 }); push @results, $row; } return \@results; diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 6207cc1..e5d3be4 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -109,7 +109,7 @@ sub dt_from_string { $regex = $fallback_re; } else { - die "Invalid dateformat parameter ($date_format)"; + carp "Invalid dateformat parameter ($date_format)"; } # Add the faculative time part [hh:mm[:ss]] -- 2.1.4