From 8ed89e1ade45ae4ee46b24626d02dcf683e472ea Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 20 Sep 2019 07:14:34 -0400 Subject: [PATCH] Bug 23624: (QA follow-up) Don't fetch the count unless the query was successful Signed-off-by: Liz Rea --- 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 58d78002e0..4ff311edb8 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -424,12 +424,15 @@ sub nb_rows { while ( $sql =~ m/$derived_name/ ) { $derived_name .= 'x'; } + my $sth = C4::Context->dbh->prepare(qq{ SELECT COUNT(*) FROM ( $sql ) $derived_name }); + $sth->execute(); - my $n = $sth->fetch->[0]; + my $results = $sth->fetch; + my $n = $results ? $results->[0] : 0; return $n; } -- 2.11.0