From d64b87b710eff0f1734d01d9383f6063198e070d Mon Sep 17 00:00:00 2001 From: dolf Date: Thu, 15 Apr 2021 09:32:30 +0200 Subject: [PATCH] Bug 21105: oai.pl returns invalid earliestDatestamp For OAI-PMH, all date and time values must be in the format "YYYY-MM-DDThh:mm:ssZ" and in UTC. Currently, Identify.earliestDatestamp uses the SQL format "YYYY-MM-DD hh:mm:ss". This patch fixes that. To test: 1) Get a Koha instance with OAI-PMH enabled. 2) Visit /cgi-bin/koha/oai.pl?verb=Identify and observe earliestDate in wrong format "YYYY-MM-DD hh:mm:ss" 3) Apply patch 4) Visit /cgi-bin/koha/oai.pl?verb=Identify and observe earliestDate in correct format "YYYY-MM-DDThh:mm:ssZ" 5) Sign off Sponsored-by: Reformational Study Centre --- Koha/OAI/Server/Identify.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Koha/OAI/Server/Identify.pm b/Koha/OAI/Server/Identify.pm index dc1a53086a..4b39579522 100644 --- a/Koha/OAI/Server/Identify.pm +++ b/Koha/OAI/Server/Identify.pm @@ -54,7 +54,13 @@ sub new { # will be returned and we will report the fallback 0001-01-01. sub _get_earliest_datestamp { my $dbh = C4::Context->dbh; - my ( $earliest ) = $dbh->selectrow_array("SELECT MIN(timestamp) AS earliest FROM biblio" ); + # We do not need to perform timezone conversion here, because the time zone + # is set to UTC for the entire SQL session in Koha/OAI/Server/Repository.pm + my $query = ' + SELECT DATE_FORMAT(MIN(timestamp), '%Y-%m-%dT%H:%i:%SZ') AS earliest + FROM biblio + '; + my ( $earliest ) = $dbh->selectrow_array($query); return $earliest } -- 2.25.1