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 <gmcharlt@gmail.com>
This commit is contained in:
Galen Charlton 2010-04-30 09:49:17 -04:00
parent e8291a15e0
commit 1cd4f42ae4
3 changed files with 12 additions and 2 deletions

View file

@ -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 );

View file

@ -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)

View file

@ -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