Summary: | Koha crashes if dateofbirth is 1947-04-27, 1948-04-25, or 1949-04-24 | ||
---|---|---|---|
Product: | Koha | Reporter: | Caroline Cyr La Rose <caroline.cyr-la-rose> |
Component: | Patrons | Assignee: | David Cook <dcook> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | minor | ||
Priority: | P5 - low | CC: | danyonsewell, dcook, gmcharlt, jonathan.druart, kyle.m.hall, lucas, philippe.blouin, shi-yao.wang |
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23079 | ||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | --- | Documentation contact: | |
Documentation submission: | Text to go in the release notes: | ||
Version(s) released in: |
23.05.00,22.11.06,22.05.14
|
Circulation function: | |
Attachments: |
Bug 32232: Ignore DST when calculating patron age
Bug 32232: Ignore DST when calculating patron age Bug 32232: Ignore DST when calculating patron age Bug 32232: Ignore DST when calculating patron age Bug 32232: Ignore DST when calculating patron age |
Description
Caroline Cyr La Rose
2022-11-16 14:25:13 UTC
The code fails in sub get_age of Koha/Patron.pm at line:
>return $today->subtract_datetime( $date_of_birth )->years;
because $date_of_birth is invalid for time zone America/Toronto
That's a tricky one. It looks like dt_from_string() silently will produce a floating timestamp where a valid local timestamp can't be produced. In this particular case, if $today were converted from local to floating, then the age in years should be able to be computed without error. After grepping around a bit, this looks like it could actually be an all right strategy. I was worried about it pushing the problem further down the line, but it looks like dateofbirth is mostly just used for display with this one exception... (In reply to Caroline Cyr La Rose from comment #0) > To test: > 1. Create a patron, setting the date of birth to one of these three dates > - 1947-04-27 > - 1948-04-25 > - 1949-04-24 > 2. Save the patron > --> Error To reproduce, you'll likely need to update <timezone></timezone> to include Canada/Eastern in your koha-conf.xml and then restart Plack. Created attachment 149737 [details] [review] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change <timezone></timezone> in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error Actually, I'm going to amend that to use the same syntax that Jonathan used in bug 23079 Created attachment 149738 [details] [review] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change <timezone></timezone> in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error Btw, it looks like t/db_dependent/Koha/Patrons.t has a unit test that covers this change. Created attachment 149754 [details] [review] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change <timezone></timezone> in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Thanks so much David! I can't vouch for the coding part, but the patch does solve the problem of accessing the patron's file. Created attachment 149758 [details] [review] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change <timezone></timezone> in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error Signed-off-by: Marius Mandrescu <marius.mandrescu@inLibro.com> Created attachment 150416 [details] [review] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change <timezone></timezone> in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error Signed-off-by: Marius Mandrescu <marius.mandrescu@inLibro.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Pushed to master for 23.05. Nice work everyone, thanks! Nice work everyone! Pushed to stable for 22.11.x Backported to 22.05.x for upcoming 22.05.14 Not backporting to 21.11.x |