Bug 27937

Summary: Date of birth entered without correct format causes internal server error
Product: Koha Reporter: Donna <bwsdonna>
Component: PatronsAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: normal    
Priority: P5 - low CC: andrew, danieldaba, fridolin.somers, gmcharlt, jonathan.druart, joonas.kylmala, kelly, kyle.m.hall, lucas, margaret, nick, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22805
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.05,20.05.11
Circulation function:
Bug Depends on:    
Bug Blocks: 28538    
Attachments: Bug 27937: Unit test
Bug 23937: Allow for single date day or month
Bug 27937: Set datepicker when date is valid
Bug 27937: Set datepicker when date is valid
Bug 27937: Set datepicker when date is valid
Bug 27937: (QA follow-up) Fix indentation
Bug 27937: Set datepicker when date is valid

Description Donna 2021-03-11 20:16:56 UTC
In 20.05 when a birthdate is entered in patron registration form (memberentry.pl) incorrectly, and save button is clicked, you receive an Internal Server Error and all the data is lost.  

To recreate:
1.  Add new patron
2.  Enter birthdate as 2/11/1986
3.  Complete required fields
4.  Save
5.  Get ISE

Yes, the text below the birthdate does specify MM/DD/YYYY but an incorrect entry should not cause all the data entered to be lost.  Perhaps a warning instead that the birthdate format is incorrect?
Comment 1 Nick Clemens (kidclamp) 2021-03-16 12:59:54 UTC Comment hidden (obsolete)
Comment 2 Nick Clemens (kidclamp) 2021-03-16 12:59:57 UTC Comment hidden (obsolete)
Comment 3 Nick Clemens (kidclamp) 2021-03-16 13:00:53 UTC Comment hidden (obsolete)
Comment 4 Nick Clemens (kidclamp) 2021-03-16 13:17:07 UTC
Created attachment 118317 [details] [review]
Bug 27937: Set datepicker when date is valid

When validating dates in JavaScript it is acceptable to have single digit days or months e.g,:
2011-6-16

When parsing in Koha::DateUtils->dt_from_string we die on these

This patch uses JS to set the datepicker which normalizes the date as Koha expects

To test:
 1 - Add new patron
 2 - Enter birthdate as 2/11/1986
 3 - Complete required fields
 4 - Save
 5 - Get ISE
     The given date (2/11/1986) does not match the date format (us) at /kohadevbox/koha/Koha/DateUtils.pm line 175
 6 - Apply patch
 7 - Repeat 1-2
 8 - Note that when you change focus (click on another field) the date is formatted as '02/11/1986'
 9 - Save patron, success!
10 - Edit patron, try setting DOB to 2/1/1986
11 - Change focus and note date is formatted as '02/01/1986', save
12 - Repeat with other settings of system preference 'dateformat'


Current status: Needs Signoff
Comment 5 ByWater Sandboxes 2021-03-17 12:03:55 UTC
Created attachment 118368 [details] [review]
Bug 27937: Set datepicker when date is valid

When validating dates in JavaScript it is acceptable to have single digit days or months e.g,:
2011-6-16

When parsing in Koha::DateUtils->dt_from_string we die on these

This patch uses JS to set the datepicker which normalizes the date as Koha expects

To test:
 1 - Add new patron
 2 - Enter birthdate as 2/11/1986
 3 - Complete required fields
 4 - Save
 5 - Get ISE
     The given date (2/11/1986) does not match the date format (us) at /kohadevbox/koha/Koha/DateUtils.pm line 175
 6 - Apply patch
 7 - Repeat 1-2
 8 - Note that when you change focus (click on another field) the date is formatted as '02/11/1986'
 9 - Save patron, success!
10 - Edit patron, try setting DOB to 2/1/1986
11 - Change focus and note date is formatted as '02/01/1986', save
12 - Repeat with other settings of system preference 'dateformat'

Signed-off-by: Donna <donna@bywatersolutions.com>
Comment 6 Joonas Kylmälä 2021-04-01 09:25:30 UTC
Created attachment 119069 [details] [review]
Bug 27937: Set datepicker when date is valid

When validating dates in JavaScript it is acceptable to have single digit days or months e.g,:
2011-6-16

When parsing in Koha::DateUtils->dt_from_string we die on these

This patch uses JS to set the datepicker which normalizes the date as Koha expects

To test:
 1 - Add new patron
 2 - Enter birthdate as 2/11/1986
 3 - Complete required fields
 4 - Save
 5 - Get ISE
     The given date (2/11/1986) does not match the date format (us) at /kohadevbox/koha/Koha/DateUtils.pm line 175
 6 - Apply patch
 7 - Repeat 1-2
 8 - Note that when you change focus (click on another field) the date is formatted as '02/11/1986'
 9 - Save patron, success!
10 - Edit patron, try setting DOB to 2/1/1986
11 - Change focus and note date is formatted as '02/01/1986', save
12 - Repeat with other settings of system preference 'dateformat'

Signed-off-by: Donna <donna@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 7 Joonas Kylmälä 2021-04-01 09:25:34 UTC
Created attachment 119070 [details] [review]
Bug 27937: (QA follow-up) Fix indentation

Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 8 Jonathan Druart 2021-04-01 16:05:30 UTC
Created attachment 119084 [details] [review]
Bug 27937: Set datepicker when date is valid

When validating dates in JavaScript it is acceptable to have single digit days or months e.g,:
2011-6-16

When parsing in Koha::DateUtils->dt_from_string we die on these

This patch uses JS to set the datepicker which normalizes the date as Koha expects

To test:
 1 - Add new patron
 2 - Enter birthdate as 2/11/1986
 3 - Complete required fields
 4 - Save
 5 - Get ISE
     The given date (2/11/1986) does not match the date format (us) at /kohadevbox/koha/Koha/DateUtils.pm line 175
 6 - Apply patch
 7 - Repeat 1-2
 8 - Note that when you change focus (click on another field) the date is formatted as '02/11/1986'
 9 - Save patron, success!
10 - Edit patron, try setting DOB to 2/1/1986
11 - Change focus and note date is formatted as '02/01/1986', save
12 - Repeat with other settings of system preference 'dateformat'

Signed-off-by: Donna <donna@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Bug 27937: (QA follow-up) Fix indentation

Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 9 Jonathan Druart 2021-04-01 16:54:50 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 10 Fridolin Somers 2021-04-13 14:55:08 UTC
Pushed to 20.11.x for 20.11.05
Comment 11 Andrew Fuerste-Henry 2021-04-24 14:00:24 UTC
Pushed to 20.05.x for 20.05.11
Comment 12 Victor Grousset/tuxayo 2021-04-24 16:51:31 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.