Bug 37382

Summary: Report download is empty except for headers if .tab format is selected
Product: Koha Reporter: Eric Swenson <eric>
Component: ReportsAssignee: CJ Lynce <cj.lynce>
Status: RESOLVED FIXED QA Contact: Lucas Gass (lukeg) <lucas>
Severity: normal    
Priority: P5 - low CC: caroline.cyr-la-rose, cj.lynce, fridolin.somers, kebliss, laura, lucas, rcoert
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Trivial patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.04
Circulation function:
Bug Depends on: 5920    
Bug Blocks:    
Attachments: Bug 37382: Report download is empty except for headers if .tab format is selected
Bug 37382: Report download is empty except for headers if .tab format is selected
Bug 37382: Report download is empty except for headers if .tab format is selected

Description Eric Swenson 2024-07-16 20:15:36 UTC
Run a report and select download as tab separated text. The downloaded file will have the first row and then empty rows for the number of results that should have been returned.
Comment 1 CJ Lynce 2024-07-26 18:57:52 UTC
I found that this issue also causes a ton of misc files to be created on the server filesystem in koha/reports/ . Each file is named something related to the exported data. 

Example
-rw-r--r--  1 kohadev-koha kohadev-koha   14 Jul 26 18:42 'Conspirator :'
-rw-r--r--  1 kohadev-koha kohadev-koha   14 Jul 26 18:42 'CSS :'
-rw-r--r--  1 kohadev-koha kohadev-koha   14 Jul 26 18:42 'Damned to fame :'
Comment 2 CJ Lynce 2024-07-26 18:58:33 UTC
Created attachment 169776 [details] [review]
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.
Comment 3 ByWater Sandboxes 2024-07-26 19:32:35 UTC
Created attachment 169780 [details] [review]
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>
Comment 4 Laura O'Neil 2024-07-26 19:35:20 UTC
I was unable to confirm the second issue of misc files created in koha/reports, but the patch fixes the data issue.
Comment 5 Lucas Gass (lukeg) 2024-08-13 15:52:29 UTC
Created attachment 170267 [details] [review]
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>
Comment 6 Katrin Fischer 2024-08-16 15:37:10 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 7 Lucas Gass (lukeg) 2024-09-06 16:34:03 UTC
Backported to 24.05.x for upcoming 24.05.04
Comment 8 Fridolin Somers 2024-09-17 14:02:29 UTC
Depends on Bug 5920 not in 23.11.x
Comment 9 Caroline Cyr La Rose 2025-04-18 19:58:02 UTC
Bug fix, nothing to add/edit in the manual.