Bugzilla – Attachment 33511 Details for
Bug 13242
Slow checkin for patrons restricted indefinitely
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13242: DateUtils should manage separately 9999-* dates
Bug-13242-DateUtils-should-manage-separately-9999-.patch (text/plain), 2.53 KB, created by
Jonathan Druart
on 2014-11-13 08:50:00 UTC
(
hide
)
Description:
Bug 13242: DateUtils should manage separately 9999-* dates
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-13 08:50:00 UTC
Size:
2.53 KB
patch
obsolete
>From 4d75a6452fe8199069c3430955ec272148dfb36c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Thu, 13 Nov 2014 09:34:43 +0100 >Subject: [PATCH] Bug 13242: DateUtils should manage separately 9999-* dates > >On bug 13226, we have seen that >my $date = DateTime->new(year => 9999, month => 12, day => 31); > => OK > >DateTime::Format::DateParse->parse_datetime( '9999-12-31' ); > => OK > >DateTime::Format::DateParse->parse_datetime( '9999-12-31', > 'America/Los_Angeles' ); > => KO (~20sec on my laptop) > >For instance if you try to check in items for a patron which is >restricted indefinitely (and there is no overdue on the item), the code >in C4::Circulation::AddReturn l~1948 > my $borrower_debar_dt = dt_from_string( $borrower->{debarred} ); >will be called. > >dt_from_string should not called >DateTime::Format::DateParse->parse_datetime with the time zone parameter >in this case. > >Test plan: >Create an indefinitely restriction for a patron and check an item in. >Without this patch, it should take ~20 sec. >With, ~2 or 3 sec. >--- > Koha/DateUtils.pm | 5 +++++ > t/DateUtils.t | 10 ++++++---- > 2 files changed, 11 insertions(+), 4 deletions(-) > >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index b372a3a..2a3543e 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -53,6 +53,11 @@ to the system preferences. If the date string is empty DateTime->now is returned > > sub dt_from_string { > my ( $date_string, $date_format, $tz ) = @_; >+ >+ if ( $date_string =~ /^9999-/ ) { >+ return DateTime::Format::DateParse->parse_datetime($date_string); >+ } >+ > if ( !$tz ) { > $tz = C4::Context->tz; > } >diff --git a/t/DateUtils.t b/t/DateUtils.t >index 9afddc1..07cd825 100755 >--- a/t/DateUtils.t >+++ b/t/DateUtils.t >@@ -1,11 +1,9 @@ >-use strict; >-use warnings; >-use 5.010; >+use Modern::Perl; > use DateTime; > use DateTime::TimeZone; > > use C4::Context; >-use Test::More tests => 34; >+use Test::More tests => 35; > use Test::MockModule; > > BEGIN { use_ok('Koha::DateUtils'); } >@@ -106,6 +104,10 @@ cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects iso day 0' ); > $dt0 = dt_from_string( '0000-00-00', 'iso' ); > is( $dt0, undef, "undefined returned for 0 iso date" ); > >+# Return undef if passed mysql 9999-* date >+my $dt9999 = dt_from_string( '9999-12-31' ); >+is( $dt9999->ymd(), '9999-12-31', "dt_from_string should return a DateTime object for 9999-12-31" ); >+ > my $formatted = format_sqldatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); > cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' ); > >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13242
:
33510
|
33511
|
33560
|
33561
|
33564
|
33565
|
33589
|
33590
|
33591
|
33592
|
33596
|
33597
|
33945