]> git.koha-community.org Git - koha.git/commit
Bug 14494: Prevent slow checkout if the patron does not have an expiry date
authorJonathan Druart <jonathan.druart@koha-community.org>
Thu, 9 Jul 2015 08:52:28 +0000 (09:52 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Wed, 29 Jul 2015 20:31:59 +0000 (08:31 +1200)
commit7eb7b6d90caeeb65fc930c34bc3f0f28603bedd9
tree604a1e71f4e2f574b143a1d0cde30cc821ea11fe
parentcede10ef4b43b69c8c9a0573e73b8c86854a8d99
Bug 14494: Prevent slow checkout if the patron does not have an expiry date

If a patron has a expiry date set to 9999-12-31 (for organizations for
instance), the checkouts are very slow.

It's caused by 2 different calls to DateTime in CanBookBeIssued:
1/
  DateTime->new( year => 9999, month => 12, day => 31, time_zone => C4::Context->tz );
The time_zone should not be set (as it's done in Koha::DateUtils), set to UTC or floating tz.

2/
  DateTime->compare($today, $expiry_dt)
The comparaison of 2 DT with 1 related to 9999 is very slow, as you can
imagine.

For 1/ we need to call Koha::DateUtils::dt_from_string (actually, we
should never call DateTime directly).
For 2/ we just need to test if the date is != 9999, no need to compare
it in this case.

Test plan:
Before this patch, confirm that the checkouts are slow if the patron has a
dateexpiry set to 9999-12-31.
update borrowers set dateexpiry="9999-12-31" where borrowernumber=42;

After this patch, you should not see any regression when checking out
items to an expired patron and to a valid patron.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
(cherry picked from commit 8d58acc565c8500d4b9d55cacb3d6d21628a899b)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Circulation.pm