I think this only happens if the server/computer is set to an Eastern Canadian timezone. In 1947, 1948 and 1949, Canada decided to switch to daylight saving time at midnight rather than the usual 2am. Therefore, 1947-04-27 00:00:00, 1948-04-25 00:00:00 and 1949-04-24 00:00:00 don't exist in this timezone. Even if borrowers.dateofbirth is set to 'date' (not 'datetime'), Koha crashes, saying the date doesn't exist. I suspect it would happen with any date, but dateofbirth is the most likely (only) field to have dates in those years. 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 I tested this on production installations in 21.05 and it works fine. Production installations in 22.05, it crashes.
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