From 068c136db98cb26128723580fb0b6b1cec0b6c9d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 28 Jan 2020 12:54:37 +0100 Subject: [PATCH] Bug 23463: (follow-up) Fix timestamp default value For discussion, this patch revert the changes made previously. This line exists in Koha::Item->store as it is the translation of: if (exists $item->{'timestamp'}) { delete $item->{'timestamp'}; } that was coming from _do_column_fixes_for_mod (called from ModItem) To preserve existing behavior I would be in favor of keeping it like that to avoid regression, and deal with it separately if we want to improve/remove it. So basically here we are setting it to undef in Koha::Item->store to make it handle correctly by the parent Koha::Object->store. I agree that's kind of weird and must be improved. Signed-off-by: Signed-off-by: Tomas Cohen Arazi Signed-off-by: Signed-off-by: Nick Clemens --- Koha/Item.pm | 4 +--- Koha/Object.pm | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index e0e1505d3a..65b55558b1 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -148,9 +148,7 @@ sub store { $self->permanent_location( $self->location ); } - if ( $self->timestamp ) { - $self->timestamp(dt_from_string); # Maybe move this to Koha::Object->store? - } + $self->timestamp(undef) if $self->timestamp; # Maybe move this to Koha::Object->store? C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ); diff --git a/Koha/Object.pm b/Koha/Object.pm index 11074498ba..fcb1e802ff 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -151,6 +151,12 @@ sub store { $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); } } + elsif ( not defined $self->$col + && $columns_info->{$col}->{datetime_undef_if_invalid} ) + { + # timestamp + $self->$col( $columns_info->{$col}->{default_value} ); + } } } -- 2.20.1