Browse Source

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 <martin.renvoize@ptfs-europe.com>
20.05.x
Jonathan Druart 1 year ago
committed by Martin Renvoize
parent
commit
ddbe2753ba
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 12
      C4/Reports/Guided.pm

12
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 );

Loading…
Cancel
Save