Bug 37382: Report download is empty except for headers if .tab format is selected

When exporting a report in tab delimited format, the downloaded file
    would have the header rows but no data results.
Also, misc files are created on the server file system in koha/reports
    with data that should have been in the .tab file.
This patch fixes both of these issues.

To test:
1. Login to staff client
2. Go to Reports and create a report from SQL - sample report
    SELECT i.barcode, b.title, b.biblionumber, i.itemnumber
	FROM items i
	LEFT JOIN biblio b on i.biblionumber = b.biblionumber
	WHERE i.itemnumber < 50
3. Run the report
4. Click 'Download'->'Tab separated text'
5. Download file
6. Open file in a text editor or favorite spreadsheet app
    File will have headers rows, but no other item data
6a. If able, check the server filesystem in koha/reports
	There may be files there related to report data. Remove.
7. Apply Patch
8. Repeat steps 3-6,
    File will now have the table data, hooray!
8a. If able, check the server filesystem in koha/reports
	No new files should be created.

Signed-off-by: Laura ONeil <laura@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
CJ Lynce 2024-07-26 18:53:37 +00:00 committed by Katrin Fischer
parent 0dad564763
commit 7d0563e1c5
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -633,7 +633,8 @@ elsif ($op eq 'export'){
$content .= join("\t", header_cell_values($sth)) . "\n";
$content = $scrubber->scrub( Encode::decode( 'UTF-8', $content ) );
while ( my $row = $sth->fetchrow_arrayref() ) {
$content .= join( "\t", $scrubber->scrub(@$row) ) . "\n";
$content .= join( "\t", map { $_ // '' } @$row ) . "\n";
$content = $scrubber->scrub( $content );
}
} else {
if ( $format eq 'csv' ) {