https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41921

--- Comment #165 from Brendan Lawlor <[email protected]> ---
Created attachment 208040
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208040&action=edit
Bug 41921: (QA follow-up) Handle missing stored report results

format_results looks up stored results by joining saved_sql to
saved_reports. Deleting a report does not delete its stored results,
so for results whose report was deleted, or for an id that does not
exist, the lookup finds no row and from_json(undef) dies.

Following a "View results" link from the Report jobs page after the
report was deleted would return 500.

This patch:
- Makes format_results return undef when no stored results are
  found
- Shows a "results do not exist" message in view_stored_results
  instead of crashing
- Adds tests for format_results, including results in the new
  headers/rows format and the older array format

Test plan:
1. Go to:
   /cgi-bin/koha/reports/guided_reports.pl?op=view_stored_results&id=99999999
2. Boom. 500 error malformed JSON string
3. Set ReportsRunInBackground to "let the user choose"
4. Run a saved report and choose "Queue as background job"
5. When the job has finished, click "View results" on the Report
   jobs page and note the results display
6. Copy that page's URL, then delete the saved report
7. Open the copied URL and note the error page (500)
8. Apply patch and restart_all
9. Repeat steps 1 and 7
10. Note both now show "These saved report results do not exist,
    or the report they belong to has been deleted."
11. Run a report as a background job again and confirm
    "View results" still shows its results
12. Run:
    prove t/db_dependent/Reports/Guide

Sponsored-by: CLAMS
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Brendan Lawlor <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to