From 148eec6bb363c44b763753cc242048c704070b33 Mon Sep 17 00:00:00 2001 From: emlam Date: Thu, 27 Jul 2023 16:36:34 +0000 Subject: [PATCH] Bug 34435: Remove side effect from get_password_expiry_date If get_password_expiry_date is passed a DateTime object as a parameter, it modifies and returns the original object. This can create possible side effects. This patch modifies get_password_expiry_date to clone the DateTime object that it receives as a parameter and return the modified clone, so that object references can be passed in safely. To test: prove t/db_dependent/Koha/Patron/Category.t Signed-off-by: Sam Lau Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit dae5607fd184c2e4b19b197cca313aca92975e47) Signed-off-by: Fridolin Somers (cherry picked from commit f067a82e3aa2d45b92415cc6cfb0fea71b0866c2) Signed-off-by: Pedro Amorim --- Koha/Patron/Category.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm index 335367b825..e24c8d6e79 100644 --- a/Koha/Patron/Category.pm +++ b/Koha/Patron/Category.pm @@ -126,7 +126,7 @@ sub get_password_expiry_date { my ($self, $date ) = @_; if ( $self->password_expiry_days ) { $date ||= dt_from_string; - $date = dt_from_string( $date ) unless ref $date; + $date = ref $date ? $date->clone() : dt_from_string( $date ); return $date->add( days => $self->password_expiry_days )->ymd; } else { return; -- 2.39.5