From bc2d1078c18a032c72c9d4371a3f39c42c9821b4 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 19 Apr 2023 13:25:25 +0300 Subject: [PATCH] Bug 32563: Cloning $self->reservedate leads to error 500 If DefaultHoldExpirationdate is set and I trap a hold and revert the hold's waiting status and then try to cancel the hold, I get an error. To test: 1. Go to /cgi-bin/koha/admin/preferences.pl?op=search&searchfield=DefaultHoldExpirationdate 2. Setup default expiration date to be 1 year from reserve date for example. 3. Switch to catalog to any biblio with item for example /cgi-bin/koha/catalogue/detail.pl?biblionumber=1 and place a hold for any borrower. 4. Check in an item from the biblio you reserved and your hold gets trapped. 5. Go to the biblio and to it's holds page and revert the waiting status of your hold. 6. Notice that expiration date is empty. 7. Cancel the hold and get an error. 8. Apply this patch. 9. Repeat step above, but now no error should be raised. Also prove prove t/db_dependent/Hold.t Sponsored-by: Koha-Suomi Oy --- Koha/Hold.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 8e314d25b9..ac0b0ff5ce 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -895,8 +895,11 @@ sub _set_default_expirationdate { my $timeunit = C4::Context->preference('DefaultHoldExpirationdateUnitOfTime') || 'days'; + my $reservedate = dt_from_string( $self->reservedate ); + my $reservedate_clone = $reservedate->clone; + $self->expirationdate( - dt_from_string( $self->reservedate->clone )->add( $timeunit => $period ) ); + $reservedate_clone->add( $timeunit => $period ) ); } =head3 _move_to_old -- 2.34.1