From f376258cb552fd95cf3710dfa4cd813a1105013f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 Mar 2020 17:21:24 +0100 Subject: [PATCH] Bug 23463: (follow-up 3) Fix timestamp default value This is the only situation I found where: * t/db_dependent/Koha/Item.t is passing * t/db_dependent/Koha/Object.t is passing * MySQL 8 is happy (and not fail with "Column 'timestamp' cannot be null"), which is certainly what I missed in the previous follow-up I think we should remove the lines from the overloaded ->store method (Item and Patron), but then we need Object.t to be adjusted. I do not understand why we would need to set updated_on, maybe the test is wrong? --- Koha/Item.pm | 4 ++-- Koha/Object.pm | 2 +- Koha/Patron.pm | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 67a2328415..aafd75a8f2 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -76,6 +76,8 @@ sub store { $self->itype($self->biblio->biblioitem->itemtype); } + $self->timestamp(undef) if $self->timestamp; # Maybe move this to Koha::Object->store? + my $today = dt_from_string; unless ( $self->in_storage ) { #AddItem unless ( $self->permanent_location ) { @@ -156,8 +158,6 @@ sub store { $self->permanent_location( $self->location ); } - $self->timestamp(undef) if $self->timestamp; # Maybe move this to Koha::Object->store? - C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ); $self->_after_item_action_hooks({ action => 'modify' }); diff --git a/Koha/Object.pm b/Koha/Object.pm index 6029217e0f..e56f4b18f4 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -155,7 +155,7 @@ sub store { && $columns_info->{$col}->{datetime_undef_if_invalid} ) { # timestamp - # $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); + $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); } } } diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 4cd9099d6a..57c3816012 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -187,6 +187,8 @@ sub store { $self->fixup_cardnumber; } + $self->updated_on(undef) if $self->updated_on; # Maybe move this to Koha::Object->store? + unless( $self->category->in_storage ) { Koha::Exceptions::Object::FKConstraint->throw( broken_fk => 'categorycode', -- 2.20.1