Koha-clms/opac
Martin Renvoize 6f62a8fe30
Bug 41919: Limit number of current reports a single user can run simultaneously
Building on bug 41918, it would be good to limit the number of reports
a given user can run at a time. This control is config-file based as
it is tied to the server resources provided by the administrator.

Adds a new koha-conf.xml option total_running_reports_per_user_limit
(0 = disabled). When the configured limit is reached, the user is told
"You have too many reports running at the moment. Please wait for some
of them to finish before running this report again."

Note on implementation: the original patch on bz (attachment 198034)
performed a second pre-flight Koha::Reports->running call in
reports/guided_reports.pl. The bug 41918 QA follow-ups already pushed
the duplicate-running guard into Koha::Report::prep_report so it would
fire across the staff UI, svc/report and opac/svc/report. This patch
extends that same model-layer architecture rather than reintroducing
controller-layer enforcement:

- New Koha::Exceptions::Report::TotalRunning subclass of
  Koha::Exceptions::Report.
- prep_report now performs a second check after the duplicate one and
  throws TotalRunning when the user has total_running_reports_per_user_limit
  reports of any kind already in flight.
- All three callers (guided_reports.pl, svc/report, opac/svc/report)
  catch the new exception alongside DuplicateRunning, mapping it to a
  new template error key total_running_reports_limit_exceeded for the
  staff UI and a JSON {error: total_running_reports_limit_exceeded}
  with HTTP 429 for the JSON endpoints.

Test Plan:
1) Set total_running_reports_per_user_limit to 3 in your koha-conf.xml.
2) Create 3 long-running reports like:
   SELECT COUNT(*) FROM items i1 JOIN items i2 JOIN items i3 JOIN items i4 JOIN items i5 JOIN items i6
3) Run each report in turn by opening a new tab, browsing to the
   reports module, and choosing to run that report.
4) Note the first three continue to run, but a fourth attempt gives
   the new "too many reports running" alert in the staff UI.
5) Repeat against /cgi-bin/koha/svc/report?id=N and confirm an HTTP
   429 response with JSON {error: total_running_reports_limit_exceeded}.
6) Set total_running_reports_per_user_limit back to 0 and confirm
   normal behaviour resumes.
7) prove t/db_dependent/Koha/Reports.t -> 13 tests pass, including a
   new subtest for TotalRunning.

Signed-off-by: Alex Carver [Acerock7] <alex@rcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-05-07 07:56:21 -06:00
..
clubs Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
errors Bug 28146: Respect ReplytoDefault in error pages 2025-10-09 14:58:41 -06:00
external/overdrive Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
sci Bug 34596: Add rebuild queue where needed for existing calls to AddReturn 2025-10-06 09:15:17 -06:00
sco Bug 23909: Block waiting holds at SCO checkout 2026-05-01 11:04:19 -06:00
svc Bug 41919: Limit number of current reports a single user can run simultaneously 2026-05-07 07:56:21 -06:00
ilsdi.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
maintenance.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
oai.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-ISBDdetail.pl Bug 38936: Use redirect_if_opac_suppressed() in opac-*detail.pl pages 2025-09-29 14:02:23 -06:00
opac-MARCdetail.pl Bug 40481: (follow-up) Simplify item loop in OPAC MARC detail 2026-03-20 11:54:32 +00:00
opac-account-pay-return.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-account-pay.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-account.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-addbybiblionumber.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-alert-subscribe.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-alert-subscriptions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-article-request-cancel.pl Bug 41558: Fix and standardize links to tab on opac-user 2026-03-05 08:33:55 -07:00
opac-authorities-home.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-authoritiesdetail.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-basket.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-blocked.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-browse.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-browser.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-changelanguage.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-course-details.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-course-reserves.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-curbside-pickups.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-detail.pl Bug 41870: Warning "Use of uninitialized value $borrowernumber" in opac-detail.pl 2026-04-10 09:48:13 -06:00
opac-discharge.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-dismiss-message.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-downloadcart.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-downloadshelf.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-export.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-holdshistory.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-ics.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-idref.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-illrequests-unauthenticated.pl Bug 36197: (QA follow-up): Adopt POST REDIRECT GET pattern 2025-04-25 08:47:11 +02:00
opac-illrequests.pl Bug 41204: Fallback to Standard earlier 2026-02-06 15:17:15 -07:00
opac-image.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-imageviewer.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-issue-note.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-library.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-main.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-memberentry.pl Bug 26355: (follow-up) Fix handling of extended attributes 2026-05-01 09:30:04 -06:00
opac-messaging.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-modrequest-suspend.pl Bug 41558: Fix and standardize links to tab on opac-user 2026-03-05 08:33:55 -07:00
opac-modrequest.pl Bug 41558: Fix and standardize links to tab on opac-user 2026-03-05 08:33:55 -07:00
opac-mymessages.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-news-rss.pl Bug 42017: Fix content type of OPAC news RSS 2026-04-09 08:27:17 -06:00
opac-overdrive-search.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-page.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-passwd.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-password-recovery.pl Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
opac-patron-consent.pl Bug 41662: Prevent CSRF on opac-patron-consent.pl 2026-01-29 15:11:21 -07:00
opac-patron-image.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-privacy.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-ratings.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-readingrecord.pl Bug 41479: Remove Baker & Taylor integration 2026-03-24 07:50:10 +01:00
opac-recall.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-recalls.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-registration-verify.pl Bug 41076: Adjust our perl tidiness for v20250105 2026-02-05 09:03:51 -07:00
opac-renew.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-reportproblem.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-request-article.pl Bug 41558: Fix and standardize links to tab on opac-user 2026-03-05 08:33:55 -07:00
opac-reserve.pl Bug 23415: (QA follow-up) Fix spelling: oweing -> owing 2026-03-22 23:15:45 +01:00
opac-reset-password.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-restrictedpage.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-retrieve-file.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-review.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-routing-lists.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-search-history.pl Bug 41454: Remove unused dbh calls 2026-04-15 09:14:51 -06:00
opac-search.pl Bug 41479: Remove Baker & Taylor integration 2026-03-24 07:50:10 +01:00
opac-sendbasket.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-sendshelf.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-serial-issues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-shareshelf.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-shelves.pl Bug 41479: Remove Baker & Taylor integration 2026-03-24 07:50:10 +01:00
opac-showmarc.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-showreviews.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-suggestions.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-tags.pl Bug 39055: Change "op" to "login_op" when logging in to allow original op to flow through 2026-03-19 10:51:27 +00:00
opac-tags_subject.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-topissues.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
opac-user.pl Bug 26355: (QA follow-up) perl tidy to address qa tool errors 2026-05-01 09:30:03 -06:00
opac-virtual-card.pl Bug 40659: (follow-up) Use UI language for custom virtual card layout 2026-04-23 16:04:13 -06:00
tracklinks.pl Bug 30261: Render opac 404 for opac/tracklinks.pl 2026-03-20 11:54:32 +00:00
unapi Bug 41261: Valid inputs to unapi 2026-04-14 10:48:48 -06:00