From dbf1bfd960a4fa931f471af75ab827d7620c497d Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Tue, 21 Sep 2021 13:28:27 -0600 Subject: [PATCH] Bug 28952 - circ/bookcount.pl - watch for timestamp == 0 Content-Type: text/plain; charset="utf-8" In MySQL 8 (probably since 5.7) Timestamp columns can't be '0'. Recent versions of DBI::Mysql seem to be quoting numbers in placeholders too, so this bit of sql because "timestamp > '0'". This causes circ/bookcount.pl, when an item has never been tranfered to filter on timestamp > '0', which causes MySQL to through an error. So convert '0' to '1970-01-01 00:00:00' in issuessince(). This could be done elsewhere in the script, but that would effect how last transfer date is shown in the template. Test Plan: Find an item that has never been transfered. Look at it's circulation history, observe the database error message. Apply patch. Reload the items circulation history, observe there is no more error. --- circ/bookcount.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/circ/bookcount.pl b/circ/bookcount.pl index 8509991ac4..8863021724 100755 --- a/circ/bookcount.pl +++ b/circ/bookcount.pl @@ -107,6 +107,9 @@ sub lastmove { sub issuessince { my ( $itemnumber, $date ) = @_; + if ( $date eq '0' ) { + $date = '1970-01-01 00:00:00'; + } my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("SELECT SUM(count) FROM ( -- 2.25.1