Bug 34435

Summary: get_password_expiry_date should not modify its parameter
Product: Koha Reporter: Emily Lamancusa (emlam) <emily.lamancusa>
Component: PatronsAssignee: Emily Lamancusa (emlam) <emily.lamancusa>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, gmcharlt, kyle.m.hall, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.03,22.11.09
Circulation function:
Bug Depends on: 34117    
Bug Blocks:    
Attachments: Bug 34435: Add unit test
Bug 34435: Remove side effect from get_password_expiry_date
Bug 34435: Add unit test
Bug 34435: Remove side effect from get_password_expiry_date
Bug 34435: Add unit test
Bug 34435: Remove side effect from get_password_expiry_date

Description Emily Lamancusa (emlam) 2023-07-27 15:09:32 UTC
If get_password_expiry_date is passed a DateTime object as a parameter, it modifies and returns the original object. Bug 34117 removed this side effect from get_expiry_date, so we should remove this side effect from get_password_expiry_date as well.
Comment 1 Emily Lamancusa (emlam) 2023-07-27 16:54:59 UTC
Created attachment 153998 [details] [review]
Bug 34435: Add unit test

To test:
prove t/db_dependent/Koha/Patron/Category.t
Comment 2 Emily Lamancusa (emlam) 2023-07-27 16:55:01 UTC
Created attachment 153999 [details] [review]
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
Comment 3 Sam Lau 2023-07-31 15:06:27 UTC
Created attachment 154100 [details] [review]
Bug 34435: Add unit test

To test:
prove t/db_dependent/Koha/Patron/Category.t

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 4 Sam Lau 2023-07-31 15:06:29 UTC
Created attachment 154101 [details] [review]
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 <samalau@gmail.com>
Comment 5 Jonathan Druart 2023-08-04 13:39:45 UTC
Created attachment 154278 [details] [review]
Bug 34435: Add unit test

To test:
prove t/db_dependent/Koha/Patron/Category.t

Signed-off-by: Sam Lau <samalau@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2023-08-04 13:39:47 UTC
Created attachment 154279 [details] [review]
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 <samalau@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Victor Grousset/tuxayo 2023-08-09 00:50:40 UTC
Now that dependency bug 34117 is passed QA, this one can be too IIUC.

Works (tests before implementation made it easy to check ﷐[U+1F44D]﷑), makes sense, QA script happy, code looks good, passing QA :)
Comment 8 Tomás Cohen Arazi (tcohen) 2023-08-15 09:17:34 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 9 Fridolin Somers 2023-08-17 20:14:24 UTC
Pushed to 23.05.x for 23.05.03
Comment 10 Pedro Amorim 2023-08-18 13:51:33 UTC
Nice work everyone!

Pushed to 22.11.x for next release