From 6b53b5c03a54978351eb61ac41b8f3f3e8571fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20R=C3=A4is=C3=A4?= Date: Tue, 8 Oct 2024 13:46:24 +0300 Subject: [PATCH] Bug 32413: Fix repeated param names for JSON report This patch fixes repeated param names for JSON report. To test: 1) Create a report SELECT count(*) from items where homebranch = <> UNION ALL SELECT count(*) from deleteditems where homebranch = <> 2) Run the report as JSON, cgi-bin/koha/svc/report?id=&sql_params= 3) Check that the second value is 0 4) Apply the patch 5) Run the report as JSON again 6) Check that the second value has the correct value Sponsored-by: Koha-Suomi Oy --- Koha/Report.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Koha/Report.pm b/Koha/Report.pm index 55daece836..23a913b61d 100644 --- a/Koha/Report.pm +++ b/Koha/Report.pm @@ -152,6 +152,12 @@ sub prep_report { } my %lookup; + unless ( scalar @$param_names ) { + my @placeholders = $sql =~ /<<([^<>]+)>>/g; + foreach my $placeholder (@placeholders) { + push @$param_names, $placeholder unless grep { $_ eq $placeholder } @$param_names; + } + } @lookup{@$param_names} = @$sql_params; @split = split /<<|>>/, $sql; for ( my $i = 0 ; $i < $#split / 2 ; $i++ ) { -- 2.34.1