Bug 8391

Summary: Cannot view reading record through staff client
Product: Koha Reporter: Kyle M Hall <kyle.m.hall>
Component: PatronsAssignee: Kyle M Hall <kyle.m.hall>
Status: CLOSED FIXED QA Contact: Jonathan Druart <jonathan.druart>
Severity: normal    
Priority: P5 - low CC: chris, gmcharlt, jonathan.druart, kyle.m.hall, kyle, paul.poulain, robin
Version: 3.8   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 8391 - Cannot view reading record through staff client
Bug 8391: prevent error when viewing circ history with bad dates
Bug 8391: prevent error when viewing circ history with bad dates

Description Kyle M Hall 2012-07-09 12:38:04 UTC
Through the staff client, circulation histroy results in an error message.
In circulation, after retrieving a borrower record, click on the "Circulation
History" button on the left hand side of the page. The below error message is a
result:

Software error:
The 'month' parameter ("0") to DateTime::new did not pass the 'an integer
between 1 and 12' callback
 at /usr/lib/perl5/DateTime.pm line 194
    DateTime::new(undef, 'hour', 00, 'minute', 00, 'month', 0, 'second', 0,
...) called at /usr/share/perl5/DateTime/Format/DateParse.pm line 58
    DateTime::Format::DateParse::parse_datetime('DateTime::Format::DateParse',
'0000-00-00 00:00:00', 'America/Los_Angeles') called at
/usr/share/koha/lib/Koha/DateUtils.pm line 86
    Koha::DateUtils::dt_from_string('0000-00-00 00:00:00', 'sql') called at
/usr/share/koha/lib/Koha/DateUtils.pm line 160
    Koha::DateUtils::format_sqldatetime('0000-00-00 00:00:00') called at
/usr/share/koha/intranet/cgi-bin/members/readingrec.pl line 80

For help, please send mail to the webmaster ([no address given]), giving this
error message and the time and date of the error.
Comment 1 Kyle M Hall 2012-07-09 12:42:01 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2012-07-17 14:56:03 UTC
> This bug reveals itself when attempting to view the reading record
> of a borrower who currently has items checked out.

In the issues table, I have returndate=NULL.
How do you manage to fill this value with '0000-00-00 00:00:00' ?
Comment 3 Robin Sheat 2012-07-27 09:33:33 UTC
I also have this issue. However, I have what I think is a fix in a more appropriate place (that is, it will sold this problem in more than just a single location.)

This occurs for me with some old data when the item was never returned (e.g. lost) and the returndate in old_issues ended up being 0000-00-00 00:00:00.

Items checked out correctly have NULL for me.

A side effect of this (which is probably best fixed separately) is that things that are lost will say "Checked Out" rather than "Lost" or similar. I will attach my patch (it's more or less the same thing in spirit.)
Comment 4 Robin Sheat 2012-07-27 09:40:19 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2012-07-30 15:41:50 UTC
Created attachment 11203 [details] [review]
Bug 8391: prevent error when viewing circ history with bad dates

Sometime the circ history will contain "0000-00-00" as a returndate when
an item was lost rather than returned. This currently causes an error
when attempting to parse the dates, this patch causes an empty string to
be returned instead.

Note: a future enhancement should distinguish between "no date provided"
and "invalid date provided" to allow distinctions to be made.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Jonathan Druart 2012-08-06 13:45:08 UTC
QA Comments:

return undef or an empty string if the argument is empty or equal "0000-00-00"

Marking as Passed QA


see Bug 8532 (same modification for the routine output_pref).
Comment 7 Chris Cormack 2012-08-06 20:51:16 UTC
Pushed to 3.8.x, will be in 3.8.4, leaving set to Passed QA so Paul can push to master when he is back
Comment 8 Paul Poulain 2012-09-03 13:43:19 UTC
Patch pushed to master

Note that it could solve some errors in other places as well.