From ddbe2753bab8a24f062d8ee4b3313c8827a88402 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Mar 2020 17:55:28 +0200 Subject: [PATCH] Bug 22001: execute reports in an eval Otherwise the tests will fail. We will certainly log twice the error when run from the UI, but not a big deal. This definitely needs more attention in a follow-up bug report. We want to raise proper exceptions here. Signed-off-by: Martin Renvoize --- C4/Reports/Guided.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 0a592b58ed..8c89165e2a 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -445,8 +445,11 @@ sub nb_rows { $dbh->{RaiseError} = $RaiseError; $dbh->{PrintError} = $PrintError; if ($@) { # To catch "Duplicate column name" caused by the derived table, or any other syntax error - $sth = $dbh->prepare($sql); - $sth->execute; + eval { + $sth = $dbh->prepare($sql); + $sth->execute; + }; + warn $@ if $@; # Loop through the complete results, fetching 1,000 rows at a time. This # lowers memory requirements but increases execution time. while (my $rows = $sth->fetchall_arrayref(undef, 1000)) { @@ -576,7 +579,10 @@ sub execute_query { $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id; my $sth = $dbh->prepare($sql); - $sth->execute(@$sql_params, $offset, $limit); + eval { + $sth->execute(@$sql_params, $offset, $limit); + }; + warn $@ if $@; return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err); return ( $sth ); -- 2.39.5