Bug 24840 - Datetime issues in automatic_renewals / CanBookBeReserved
Summary: Datetime issues in automatic_renewals / CanBookBeReserved
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-10 14:13 UTC by Nick Clemens
Modified: 2020-11-30 21:47 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06


Attachments
Bug 24840: Replace DateTime->now with dt_from_string (24.09 KB, patch)
2020-03-26 11:10 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 24840: Replace DateTime->now with dt_from_string (23.96 KB, patch)
2020-04-08 09:45 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24840: Catch some further cases of DateTime->now (4.21 KB, patch)
2020-04-08 09:45 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 24840: Replace DateTime->now with dt_from_string (24.03 KB, patch)
2020-04-08 10:23 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24840: Catch some further cases of DateTime->now (4.29 KB, patch)
2020-04-08 10:23 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 24840: [19.11.x] Replace DateTime->now with dt_from_string (28.20 KB, patch)
2020-05-06 15:23 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2020-03-10 14:13:20 UTC
I cannot recreate this, however, we have sites that experience automatic_renewals.pl crashing with:
Invalid local time for date in time zone: America/New_York

It seems to happen around the daylight savings change
There is:
DateTime->now( time_zone => C4::Context->tz() ) 
In C4::Circulation::CanBookBeRenewed but I can't purposely make that fail
Comment 1 Jonathan Druart 2020-03-10 18:57:27 UTC
We should not use DateTime directly, but dt_from_string from Koha::DateUtils instead.

See also bug 23079 for more info.

To recreate:

use DateTime;
say DateTime->new(year => 2020, month => 3, day => 8, hour => 2, time_zone => 'America/New_York');


I guess your auto renew cronjob run at 2am.
Comment 2 Nick Clemens 2020-03-26 11:10:24 UTC
Created attachment 101802 [details] [review]
Bug 24840: Replace DateTime->now with dt_from_string

We should use Koha::DateUtils instead of Date::Time directly

This patch simplay replaces calls to now() with a call to dt_from_string()
which does effectively the same thing.

Probably reading the code and verifying changes is sufficient but...

To test:
1 - confirm the files all compile
2 - confirm all tests pass
3 - confirm Koha still works
Comment 3 Martin Renvoize 2020-04-08 09:45:36 UTC
Created attachment 102542 [details] [review]
Bug 24840: Replace DateTime->now with dt_from_string

We should use Koha::DateUtils instead of Date::Time directly

This patch simplay replaces calls to now() with a call to dt_from_string()
which does effectively the same thing.

Probably reading the code and verifying changes is sufficient but...

To test:
1 - confirm the files all compile
2 - confirm all tests pass
3 - confirm Koha still works

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2020-04-08 09:45:39 UTC
Created attachment 102543 [details] [review]
Bug 24840: Catch some further cases of DateTime->now

This patch corrects a few additional cases where DateTime->now is called
directly instead of via Koha::DateUtils.
Comment 5 Martin Renvoize 2020-04-08 09:46:21 UTC
Tests all continue to pass.. looks good to me.  Signing off
Comment 6 Jonathan Druart 2020-04-08 10:23:22 UTC
Created attachment 102550 [details] [review]
Bug 24840: Replace DateTime->now with dt_from_string

We should use Koha::DateUtils instead of Date::Time directly

This patch simplay replaces calls to now() with a call to dt_from_string()
which does effectively the same thing.

Probably reading the code and verifying changes is sufficient but...

To test:
1 - confirm the files all compile
2 - confirm all tests pass
3 - confirm Koha still works

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2020-04-08 10:23:25 UTC
Created attachment 102551 [details] [review]
Bug 24840: Catch some further cases of DateTime->now

This patch corrects a few additional cases where DateTime->now is called
directly instead of via Koha::DateUtils.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2020-04-08 10:28:32 UTC
Great patch Nick, we really needed that!
Comment 9 Martin Renvoize 2020-04-08 10:55:27 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 10 Joy Nelson 2020-05-04 20:46:41 UTC
does not apply to 19.11.x branch.  please rebase if needed.
Comment 11 Nick Clemens 2020-05-06 15:23:31 UTC
Created attachment 104438 [details] [review]
Bug 24840: [19.11.x] Replace DateTime->now with dt_from_string

We should use Koha::DateUtils instead of Date::Time directly

This patch simplay replaces calls to now() with a call to dt_from_string()
which does effectively the same thing.

Probably reading the code and verifying changes is sufficient but...

To test:
1 - confirm the files all compile
2 - confirm all tests pass
3 - confirm Koha still works

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Bug 24840: Catch some further cases of DateTime->now

This patch corrects a few additional cases where DateTime->now is called
directly instead of via Koha::DateUtils.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Joy Nelson 2020-05-07 17:32:50 UTC
Thanks for the rebase - backported to 19.11.x for 19.11.06