Bug 34435 - get_password_expiry_date should not modify its parameter
Summary: get_password_expiry_date should not modify its parameter
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Emily Lamancusa
QA Contact: Testopia
URL:
Keywords:
Depends on: 34117
Blocks:
  Show dependency treegraph
 
Reported: 2023-07-27 15:09 UTC by Emily Lamancusa
Modified: 2023-12-28 20:47 UTC (History)
4 users (show)

See Also:
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


Attachments
Bug 34435: Add unit test (1.40 KB, patch)
2023-07-27 16:54 UTC, Emily Lamancusa
Details | Diff | Splinter Review
Bug 34435: Remove side effect from get_password_expiry_date (1.25 KB, patch)
2023-07-27 16:55 UTC, Emily Lamancusa
Details | Diff | Splinter Review
Bug 34435: Add unit test (1.44 KB, patch)
2023-07-31 15:06 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 34435: Remove side effect from get_password_expiry_date (1.30 KB, patch)
2023-07-31 15:06 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 34435: Add unit test (1.52 KB, patch)
2023-08-04 13:39 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 34435: Remove side effect from get_password_expiry_date (1.37 KB, patch)
2023-08-04 13:39 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emily Lamancusa 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 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 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 👍), makes sense, QA script happy, code looks good, passing QA :)
Comment 8 Tomás Cohen Arazi 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