Bug 27937 - Date of birth entered without correct format causes internal server error
Summary: Date of birth entered without correct format causes internal server error
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Joonas Kylmälä
URL:
Keywords:
Depends on:
Blocks: 28538
  Show dependency treegraph
 
Reported: 2021-03-11 20:16 UTC by Donna
Modified: 2022-06-06 20:24 UTC (History)
11 users (show)

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


Attachments
Bug 27937: Unit test (1.17 KB, patch)
2021-03-16 12:59 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23937: Allow for single date day or month (2.34 KB, patch)
2021-03-16 12:59 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 27937: Set datepicker when date is valid (1.66 KB, patch)
2021-03-16 13:17 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 27937: Set datepicker when date is valid (1.71 KB, patch)
2021-03-17 12:03 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 27937: Set datepicker when date is valid (1.85 KB, patch)
2021-04-01 09:25 UTC, Joonas Kylmälä
Details | Diff | Splinter Review
Bug 27937: (QA follow-up) Fix indentation (1.06 KB, patch)
2021-04-01 09:25 UTC, Joonas Kylmälä
Details | Diff | Splinter Review
Bug 27937: Set datepicker when date is valid (1.96 KB, patch)
2021-04-01 16:05 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 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 2021-03-16 12:59:54 UTC Comment hidden (obsolete)
Comment 2 Nick Clemens 2021-03-16 12:59:57 UTC Comment hidden (obsolete)
Comment 3 Nick Clemens 2021-03-16 13:00:53 UTC Comment hidden (obsolete)
Comment 4 Nick Clemens 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.