From 1cd4f42ae4bc7a14adfe111b7308443c487eea19 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 30 Apr 2010 09:49:17 -0400 Subject: [PATCH] bug 1532: ensure that empty hold request expiration is represented as NULL Fixes bug reported by Colin Campbell where reserves.expiratedate was defaulting to '0000-00-00' instead of NULL. Signed-off-by: Galen Charlton --- C4/Reserves.pm | 6 +++++- installer/data/mysql/updatedatabase.pl | 6 ++++++ kohaversion.pl | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b4c6b43abc..6328d174fd 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -142,7 +142,11 @@ sub AddReserve { my $const = lc substr( $constraint, 0, 1 ); $resdate = format_date_in_iso( $resdate ) if ( $resdate ); $resdate = C4::Dates->today( 'iso' ) unless ( $resdate ); - $expdate = format_date_in_iso( $expdate ) if ( $expdate ); + if ($expdate) { + $expdate = format_date_in_iso( $expdate ); + } else { + undef $expdate; # make reserves.expirationdate default to null rather than '0000-00-00' + } if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) { # Make room in reserves for this before those of a later reserve date $priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority ); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 778319f6d4..d5ccfe2ccf 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3564,6 +3564,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.01.00.130"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'"); + print "Upgrade done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/kohaversion.pl b/kohaversion.pl index 884c0e2ab4..509c6e225d 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.01.00.129'; + our $VERSION = '3.01.00.130'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.20.1