From 8b67fa82627cc4ce602fa7e2f79ce1e96638e480 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Thu, 7 Oct 2021 14:31:10 +0000
Subject: [PATCH] Bug 29192: Set expirationdate as string when storing Hold

To test:
 1 - Enable HoldsLog in system preferences
 2 - Set system preferences:
    DefaultHoldExpirationDate: Set
    DefaultHoldExpirationdatePeriod: 5
    DefaultHoldExpirationdateUnitOfTime: days
 3 - Create a hold for a patron
 4 - Note the expiration date is set
 5 - Check the action logs - SELECT * FROM action_logs
 6 - Note that there is a lot of data, this is from DateTime object in expirationdate
 7 - Apply patch
 8 - Restart all
 9 - Place another hold
10 - Confirm expiration date set correctly
11 - View the logs
12 - Entry for new hold contains only the date, no extra data

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
---
 Koha/Hold.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Koha/Hold.pm b/Koha/Hold.pm
index 26c41d7924..54a5aba5a1 100644
--- a/Koha/Hold.pm
+++ b/Koha/Hold.pm
@@ -624,7 +624,7 @@ sub _set_default_expirationdate {
       C4::Context->preference('DefaultHoldExpirationdateUnitOfTime') || 'days';
 
     $self->expirationdate(
-        dt_from_string( $self->reservedate )->add( $timeunit => $period ) );
+        dt_from_string( $self->reservedate )->add( $timeunit => $period )->strftime("%Y-%m-%d") );
 }
 
 =head3 _move_to_old
-- 
2.20.1