Date of Birth sometimes off by a month in patron edit form

Bug #1774427 reported by Terran McCanna
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
High
Unassigned
3.0
Fix Released
High
Unassigned

Bug Description

We're seeing very strange behavior in the patron edit form with the date of birth not always loading correctly. I've tested this on our production servers as well as on demo.evergreencatalog.com. To test, I've selected an account and edited the month and saved it - when the page reloads, the correct date of birth shows on the summary bar, but depending on the month, it sometimes loads incorrectly in the form - if staff then save the form with the incorrect date, then the patron's birth date gets saved incorrectly which is a critical problem.

It does not appear to make a difference what the settings for date format are (we have mm/dd/yyyy on our production, and the demo server has yy/mm/dd) and it does not seem to be a difference between Chrome and Firefox. The day and year do not appear to be affected by this bug.

Example account on the community demo server:
https://demo.evergreencatalog.com/eg/staff/circ/patron/132/edit
Login: admin / demo123

My test results with this account:
Changed dob to 71-01-05 --- ok
Changed dob to 71-02-05 --- form reloaded as 71-03-05
Changed dob to 71-03-05 --- ok
Changed dob to 71-04-05 --- form reloaded as 71-05-05
Changed dob to 71-05-05 --- ok
Changed dob to 71-06-05 --- form reloaded as 71-07-05
Changed dob to 71-07-05 --- ok
Changed dob to 71-08-05 --- ok
Changed dob to 71-09-05 --- form reloaded as 71-10-05
Changed dob to 71-10-05 --- ok
Changed dob to 71-11-05 --- form reloaded as 71-12-05
Changed dob to 71-12-05 --- ok

Revision history for this message
Terran McCanna (tmccanna) wrote :
Revision history for this message
Remington Steed (rjs7) wrote :

When loading the patron editor, I see a lot of date related console output. Here's what I see for that example patron, after saving the DOB as 71-02-05:

changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
egNet open-ils.circ.open_non_cataloged_circulation.user.authoritative (net.js:96:9)
egNet open-ils.actor.usergroup.members.balance_owed (net.js:96:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
changing field dob to undefined (regctl.js:1715:9)
changing field expire_date to undefined (regctl.js:1715:9)
egNet open-ils.actor.user.has_work_perm_at.batch (net.js:96:9)
changing field dob to Fri Mar 05 1971 10:40:59 GMT-0500 (Eastern Standard Time) (regctl.js:1715:9)
changing field expire_date to Tue Apr 18 2017 13:30:03 GMT-0400 (Eastern Daylight Time) (regctl.js:1715:9)
changing field dob to Fri Mar 05 1971 10:40:59 GMT-0500 (Eastern Standard Time) (regctl.js:1715:9)
changing field expire_date to Tue Apr 18 2017 13:30:03 GMT-0400 (Eastern Daylight Time) (regctl.js:1715:9)
changing field dob to Fri Mar 05 1971 10:40:59 GMT-0500 (Eastern Standard Time) (regctl.js:1715:9)
changing field expire_date to Tue Apr 18 2017 13:30:03 GMT-0400 (Eastern Daylight Time) (regctl.js:1715:9)
changing field dob to Fri Mar 05 1971 10:40:59 GMT-0500 (Eastern Standard Time) (regctl.js:1715:9)
changing field expire_date to Tue Apr 18 2017 13:30:03 GMT-0400 (Eastern Daylight Time)

Bill Erickson (berick)
Changed in evergreen:
assignee: nobody → Bill Erickson (berick)
status: New → Confirmed
status: Confirmed → In Progress
Revision history for this message
Bill Erickson (berick) wrote :

Fix pushed:

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1774427-dob-shows-wrong-month

==
From the commit for future reference:

Fixes DoB parsing in the browser client patron edit interface by creating date objects from a whole YMD date string instead of compiling the date as collection of pieces. Compiling dates from pieces (calling setFullYear(), setMonth(), etc.) can have unexpected consequences, because a change of month can result in a change of days as well, if the number of days in the date object exceeds the capacity of the selected month.

For example:

---
> d = new Date()
2018-05-31T14:59:26.186Z
> d.setMonth(1)
1520092766186
> d
2018-03-03T15:59:26.186Z
--

Parsing as Date(YYYY,MM,DD) instead avoids this kind of shuffling.

To test

[1] Log in to the staff client on the 31st day of the month :)
[2] Change a patron's DoB to a month that does not contain 31 days.
[3] Save patron and note on reload, the DoB shows the wrong value.

Changed in evergreen:
milestone: none → 3.1.3
status: In Progress → Confirmed
assignee: Bill Erickson (berick) → nobody
tags: added: pullrequest
Revision history for this message
Terran McCanna (tmccanna) wrote :

I have tested this code and consent to signing off on it with my name, Terran McCanna and my email address, <email address hidden>

tags: added: signedoff
Revision history for this message
Kathy Lussier (klussier) wrote :

Works for me too! Pushed to master, 3.1 and 3.0. Thanks Bill and Terran!

Changed in evergreen:
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.