From e2ebdeb02f7437cc3f4a23d3d2441ea330ee830a Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 21 Jan 2021 17:01:09 +0100 Subject: [PATCH] Bug 27511: Don't use NOW() in saved sql last run update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running a report, column last run is updated with current date-time. We should avoid using NOW(), better calculated date-time in perl. With NOW(), when importing a backup dump, you get current date-time in all rows. Also, sometimes we see errors in plack logs : DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction [for Statement "UPDATE saved_sql SET last_run = NOW() WHERE id = ?"] at /home /koha/src/C4/Reports/Guided.pm line 576. Replacing NOW() should avoid this. Test plan: 1) Run a sql report 2) Check last run date and time is OK Signed-off-by: Séverine QUEUNE --- C4/Reports/Guided.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index a76d86ba44..483c34814c 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -588,7 +588,10 @@ sub execute_query { my $dbh = C4::Context->dbh; - $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id; + if ($report_id) { + my $now = output_pref( { dt => dt_from_string(), dateformat => 'iso' } ); + $dbh->do( 'UPDATE saved_sql SET last_run = ? WHERE id = ?', undef, $now, $report_id ); + } my $sth = $dbh->prepare($sql); eval { -- 2.11.0