Koha-clms/reports
Martin Renvoize 4227119b63
Bug 41918: (QA follow-up) Catch DuplicateRunning in op=export path
The CSV/tab export branch (op=export) of reports/guided_reports.pl
calls Koha::Report::prep_report just like the op=run branch and the
two svc/report endpoints, but unlike the others it had no eval/catch
around the call. The QA follow-ups that pushed enforcement into the
model layer therefore left this one path emitting a 500 (uncaught
Koha::Exceptions::Report::DuplicateRunning) when the configured
duplicate-running limit is exceeded.

Wrap the call in the same pattern as svc/report: on
DuplicateRunning return HTTP 429 Too Many Requests with a plain-text
body explaining the situation. Plain text rather than the staff
template because op=export sets file-download headers and the user is
expecting either the file or an error - we don't have a sensible way
to fall back into the report-run template from this branch.

The CLI runners (misc/cronjobs/runreport.pl, misc/export_records.pl)
still bypass prep_report and therefore the limit, which is intended:
scheduled / batch jobs should not be subject to user-quota
enforcement.

Test plan:
1) Set duplicate_running_reports_per_user_limit=1 in koha-conf.xml,
   restart_all.
2) Start a long-running report from the staff UI.
3) While it is running, navigate to op=export with the same report
   id (eg. via the "Export" button).
4) Before the patch: 500 with a stack trace in the logs.
   After the patch: 429 with body "This report is already running.
   Please wait for it to finish before running it again."
5) Set the limit back to 0 and confirm exports work normally again.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-05-07 07:56:20 -06:00
..
acquisitions_stats.pl Bug 41599: Fix output_error in acquisitions_stats.pl 2026-02-26 09:04:18 -07:00
bor_issues_top.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
borrowers_out.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
borrowers_stats.pl Bug 40287: Fix untranslatable strings in more statistics wizards 2025-12-17 13:24:31 -07:00
cash_register_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
cat_issues_top.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
catalog_by_itemtype.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
catalogue_out.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
catalogue_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
dictionary.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
guided_reports.pl Bug 41918: (QA follow-up) Catch DuplicateRunning in op=export path 2026-05-07 07:56:20 -06:00
issues_avg_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
issues_stats.pl Bug 41715: Argument "YYYY-MM-DD" isn't numeric in numeric lt (<)... warnings in issues_stats.pl 2026-03-05 08:33:57 -07:00
itemslost.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
orders_by_fund.pl Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
reports-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
reserves_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
serials_stats.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00