Bug 37542 - Patron search is incorrectly parsing entries as dates and fetching the wrong patron if dateofbirth in search fields
Summary: Patron search is incorrectly parsing entries as dates and fetching the wrong ...
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Brendan Lawlor
QA Contact: Nick Clemens (kidclamp)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-31 19:37 UTC by Nick Clemens (kidclamp)
Modified: 2024-12-05 18:24 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.04
Circulation function:


Attachments
Bug 37542: Fix patron search when dateofbirth is a DefaultPatronSearchField (1.59 KB, patch)
2024-08-21 16:01 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 37542: Fix patron search when dateofbirth is a DefaultPatronSearchField (1.65 KB, patch)
2024-08-22 13:05 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2024-07-31 19:37:59 UTC
When parsing patron search we try to convert the input into a date for searching against dateofbirth if included in defaultpatronsearchfields

This can lead to odd values being converted to incorrect dates.

To recreate"
1 - Create a patron with dateofbirth 1994-07-27
2 - Add dateofbirth to DefaultPatronSearchFields
3 - In patron or checkout search, type a  cardnumber like '2908800092528'
4 - Note the patron with that birth date is found in autocomplete
5 - Open the browser console (F12)
6 - In the network tab, find the last request (or just remove and add a digit)
7 - Copy the URL from that request and paste into a text editor
8 - Search for 'dateofbirth'
9 - See that the entry has been converted to 1994-07-27
Comment 1 Brendan Lawlor 2024-08-21 16:01:39 UTC
Created attachment 170571 [details] [review]
Bug 37542: Fix patron search when dateofbirth is a DefaultPatronSearchField

This patch updates the call to dayjs to use strict parsing for patron search. See https://day.js.org/docs/en/parse/string-format

To test:
1. Create a patron with dateofbirth 1994-07-27
2. Add dateofbirth to DefaultPatronSearchFields
3. In patron or checkout search, type a cardnumber like '2908800092528'
4. Note the patron with that birth date is found in autocomplete
5. Apply patch and restart_all
6. Repeat step 3 and notice the patron is no longer found
7. In patron or checkout search, try searches using a formatted date
8. Confirm searches for '07/27/1994' and '1994-07-27' find the patron
Comment 2 Nick Clemens (kidclamp) 2024-08-22 13:05:34 UTC
Created attachment 170609 [details] [review]
Bug 37542: Fix patron search when dateofbirth is a DefaultPatronSearchField

This patch updates the call to dayjs to use strict parsing for patron search. See https://day.js.org/docs/en/parse/string-format

To test:
1. Create a patron with dateofbirth 1994-07-27
2. Add dateofbirth to DefaultPatronSearchFields
3. In patron or checkout search, type a cardnumber like '2908800092528'
4. Note the patron with that birth date is found in autocomplete
5. Apply patch and restart_all
6. Repeat step 3 and notice the patron is no longer found
7. In patron or checkout search, try searches using a formatted date
8. Confirm searches for '07/27/1994' and '1994-07-27' find the patron

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 3 Nick Clemens (kidclamp) 2024-08-22 13:06:03 UTC
Trivial patch, big impact, moving to PQA
Comment 4 Katrin Fischer 2024-08-23 16:22:34 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 5 Lucas Gass (lukeg) 2024-09-12 22:34:39 UTC
Backported to 24.05.x for upcoming 24.05.04
Comment 6 Jonathan Druart 2024-10-15 08:06:23 UTC
I would like to note that the test plan focuses on dob patron search, but date_to_rfc is actually use for all the date searches using DT/REST API. As well in UsageStatisticsDataProvidersList.vue.

Side-effects are possible. However I think it's a correct change, maybe we should also apply it to other functions from js-date-format.inc
Comment 7 Fridolin Somers 2024-10-21 12:38:07 UTC
I prefer not impact oldstable since side-effects are possible