From 528aa88b7e7978b25331258f4f69274a3c21945f 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 Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize (cherry picked from commit f2b27975679e64722f06b175e759801227a313fc) Signed-off-by: Fridolin Somers --- 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.39.5