Bug 34117: Remove side effect from get_expiry_date
authorEmily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Thu, 20 Jul 2023 17:41:15 +0000 (13:41 -0400)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 17 Aug 2023 19:06:04 +0000 (09:06 -1000)
commit1628791ca24a44bf07e224f2194f12ebfe60779c
tree2fc525e210844926358be991f0ff0c7133d1304b
parent9916e1853462d293eac5eecbf15184d360d58079
Bug 34117: Remove side effect from get_expiry_date

If get_expiry_date is passed a DateTime object as a parameter,
it modifies and returns the original object. When memberentry.pl
prefills the input fields for duplicating a patron, it passes the
enrollment date object to get_expiry_date. This causes the enrollment
date object to be modified with the expiry date value.

This patch modifies get_expiry_date to clone the DateTime object that it
receives as a parameter and return the clone, so that references to an
enrollment date object can be passed in safely.

To test:
1. Have or make a patron
2. Duplicate that patron
3. Before saving the new patron, scroll down to Registration Date and
   see that it's defaulting to a date in the future.
4. Apply patch and restart_all
5. Try duplicating a patron again
6. Registration Date should correctly set to today

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit bba9feff5ca9e1601a38408625cf7ba40b70645f)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/Patron/Category.pm