Bug 28952 - Item Checkout History fails
Summary: Item Checkout History fails
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: 21.05
Hardware: PC Linux
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-03 17:53 UTC by beardst
Modified: 2021-09-23 14:09 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
MySQL output (74.80 KB, image/png)
2021-09-03 17:53 UTC, beardst
Details
Proposed patch (1.43 KB, patch)
2021-09-21 19:32 UTC, Michael Hafen
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description beardst 2021-09-03 17:53:01 UTC
Created attachment 124504 [details]
MySQL output

We are getting an error whenever trying to view an item's checkout history. This is happening on all items that we have tested

/cgi-bin/koha/circ/bookcount.pl?&biblionumber=33518&itm=18222

Results in a 500 error

The Plack error log reports

CGI::Compile::ROOT::usr_share_koha_intranet_cgi_2dbin_circ_bookcount_2epl::issuessince(): DBI Exception: DBD::mysql::st execute failed: Incorrect TIMESTAMP value: '0' [for Statement "SELECT SUM(count) FROM (
                        SELECT COUNT(*) AS count FROM issues WHERE itemnumber = ? and timestamp > ?
                        UNION ALL
                        SELECT COUNT(*) AS count FROM old_issues WHERE itemnumber = ? and timestamp > ?
                     ) tmp" with ParamValues: 0="18222", 1=0, 2="18222", 3=0] at /usr/share/koha/intranet/cgi-bin/circ/bookcount.pl line 63


If I run the above sql statement with the variables populated it returns information. Screenshot is attached.
Comment 1 Michael Hafen 2021-09-21 19:08:28 UTC
I also ran into this error.

The reason it seemed to work from the sql is that the placeholder causes the '0' to be quoted.  Try the sql with the '0' quoted and you will see the same error.

Not sure what the best way to handle this is.  Perhaps watch for $date eq 0 in the issuessince() sub and convert it to '1970-01-01 00:00:00'?

(In reply to beardst from comment #0)
> Created attachment 124504 [details]
> MySQL output
> 
> We are getting an error whenever trying to view an item's checkout history.
> This is happening on all items that we have tested
> 
> /cgi-bin/koha/circ/bookcount.pl?&biblionumber=33518&itm=18222
> 
> Results in a 500 error
> 
> The Plack error log reports
> 
> CGI::Compile::ROOT::usr_share_koha_intranet_cgi_2dbin_circ_bookcount_2epl::
> issuessince(): DBI Exception: DBD::mysql::st execute failed: Incorrect
> TIMESTAMP value: '0' [for Statement "SELECT SUM(count) FROM (
>                         SELECT COUNT(*) AS count FROM issues WHERE
> itemnumber = ? and timestamp > ?
>                         UNION ALL
>                         SELECT COUNT(*) AS count FROM old_issues WHERE
> itemnumber = ? and timestamp > ?
>                      ) tmp" with ParamValues: 0="18222", 1=0, 2="18222",
> 3=0] at /usr/share/koha/intranet/cgi-bin/circ/bookcount.pl line 63
> 
> 
> If I run the above sql statement with the variables populated it returns
> information. Screenshot is attached.
Comment 2 Michael Hafen 2021-09-21 19:32:33 UTC
Created attachment 125121 [details] [review]
Proposed patch

One possible solution.
Comment 3 beardst 2021-09-23 14:09:28 UTC
That fixed it for us. Thanks for the patch