Bug 25617

Summary: Error on about page when TimeFormat preference is set to 12hr
Product: Koha Reporter: Owen Leonard <oleonard>
Component: System AdministrationAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: critical    
Priority: P5 - low CC: aleisha, gmcharlt, jonathan.druart, julian.maurice, tomascohen, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.07, 19.05.12
Bug Depends on: 25133    
Bug Blocks:    
Attachments: Bug 25617: Pass 24hr to output_pref
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0
Bug 25617: (QA follow-up) Add responses to tests
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0
Bug 25617: (QA follow-up) Add responses to tests

Description Owen Leonard 2020-05-28 13:00:35 UTC
If the  TimeFormat system preference is set to 12-hour format the about page explodes with an error, "Template process failed: undef error - Validation failed for type named Hour declared in package DateTime::Types (/usr/lib/x86_64-linux-gnu/perl5/5.24/DateTime/Types.pm) at line 101 in sub named (eval) with value 24"
Comment 1 Owen Leonard 2020-05-28 13:07:56 UTC
Created attachment 105412 [details] [review]
Bug 25617: Pass 24hr to output_pref

This patch changes the date formatting function used to create the
current_date_and_time variable by adding '24hr' as the timeformat
parameter. This avoids an error when the TimeFormat preference is set to
12hr.

To test, apply the patch and go to the "About" page in the staff
interface. It should work correctly. The "Date and time" information
under the "Server information" tab should be correct.
Comment 2 Jonathan Druart 2020-05-28 13:53:41 UTC
Template process failed: undef error - Validation failed for type named Hour declared in package DateTime::Types (/usr/lib/x86_64-linux-gnu/perl5/5.24/DateTime/Types.pm) at line 101 in sub named (eval) with valu
e 24                                                                                                                                                                                                                                                                                                                                                                                                     
Trace begun at Specio::Exception->new line 57                                                                                                                                                                      Specio::Exception::throw('Specio::Exception', 'message', 'Validation failed for type named Hour declared in package DateTime::Types (/usr/lib/x86_64-linux-gnu/perl5/5.24/DateTime/Types.pm) at line 101 in sub nam
ed (eval) with value 24', 'type', 'Specio::Constraint::Simple=HASH(0x5602f411a6f8)', 'value', 24) called at (eval 217) line 126          
DateTime::_check_new_params('month', 05, 'day', 28, 'second', 0, 'year', 2020, 'minute', 49, 'hour', 24, 'time_zone', 'floating') called at /usr/lib/x86_64-linux-gnu/perl5/5.24/DateTime.pm line 165    
DateTime::new('DateTime', 'month', 05, 'day', 28, 'second', 0, 'year', 2020, 'minute', 49, 'hour', 24, 'time_zone', 'floating') called at /kohadevbox/koha/Koha/DateUtils.pm line 200                              
Koha::DateUtils::dt_from_string('2020-05-28 12:49 PM', 'iso') called at /kohadevbox/koha/Koha/Template/Plugin/KohaDates.pm line 34                                                                                
Koha::Template::Plugin::KohaDates::filter('Koha::Template::Plugin::KohaDates=HASH(0x560309b36c28)', '2020-05-28 12:49 PM', 'ARRAY(0x5603099fe908)', 'HASH(0x5603098a3928)') called at /usr/lib/x86_64-linux-gnu/per
l5/5.24/Template/Plugin/Filter.pm line 82                                                                                                                               
Template::Plugin::Filter::__ANON__('2020-05-28 12:49 PM') called at /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt line 127                 
eval {...} at /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt line 18                                                                                                             
Template::Provider::__ANON__('Template::Context=HASH(0x56030151f128)') called at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Document.pm line 163                                                        
eval {...} at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Document.pm line 161
Template::Document::process('Template::Document=HASH(0x560309b36880)', 'Template::Context=HASH(0x56030151f128)') called at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Context.pm line 351
eval {...} at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Context.pm line 321
Template::Context::process('Template::Context=HASH(0x56030151f128)', 'Template::Document=HASH(0x560309b36880)') called at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Service.pm line 94                         
eval {...} at /usr/lib/x86_64-linux-gnu/perl5/5.24/Template/Service.pm line 91     
Template::Service::process('Template::Service=HASH(0x5602fe764610)', '/kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt', 'HASH(0x5603097ff4b0)') called at /usr/lib/x86_64-linux-gnu/perl5/5.24/Te
mplate.pm line 66                                                                                                   
Template::process('Template=HASH(0x560301521550)', '/kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt', 'HASH(0x5603097ff4b0)', 'SCALAR(0x5602f7c2a138)') called at /kohadevbox/koha/C4/Templates.p
m line 122
Comment 3 Tomás Cohen Arazi 2020-05-28 13:59:45 UTC
What OS? I cannot reproduce on Stretch
Comment 4 Jonathan Druart 2020-05-28 14:08:48 UTC
Maybe something else actually.
Comment 5 Jonathan Druart 2020-05-28 14:09:04 UTC
It's only happening when hour=12. I am working on it.
Comment 6 Jonathan Druart 2020-05-28 14:37:19 UTC
Created attachment 105417 [details] [review]
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0

There was an error in the precedent code, in 12hr format, 12PM is
actually 00:00
Comment 7 Jonathan Druart 2020-05-28 14:38:55 UTC
Created attachment 105418 [details] [review]
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0

There was an error in the precedent code, in 12hr format, 12PM is
actually 00:00
Comment 8 Jonathan Druart 2020-05-28 14:39:43 UTC
Upping severity, not sure how big this is for TimeFormat=12hr
Comment 9 Nick Clemens (kidclamp) 2020-05-28 17:38:21 UTC
Created attachment 105422 [details] [review]
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0

There was an error in the precedent code, in 12hr format, 12PM is
actually 00:00

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Nick Clemens (kidclamp) 2020-05-28 17:38:24 UTC
Created attachment 105423 [details] [review]
Bug 25617: (QA follow-up) Add responses to tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 11 Julian Maurice 2020-05-29 08:53:47 UTC
Created attachment 105431 [details] [review]
Bug 25617: (bug 25133 follow-up) 12 PM is not 24 but 0

There was an error in the precedent code, in 12hr format, 12PM is
actually 00:00

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 12 Julian Maurice 2020-05-29 08:53:51 UTC
Created attachment 105432 [details] [review]
Bug 25617: (QA follow-up) Add responses to tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Comment 13 Jonathan Druart 2020-05-29 09:49:22 UTC
Pushed to master for 20.05
Comment 14 Aleisha Amohia 2020-06-14 21:44:56 UTC
backported to 19.11.x for 19.11.07
Comment 15 Victor Grousset/tuxayo 2020-06-17 19:56:37 UTC
Backported to 19.05.x branch for 19.05.12