Bugzilla – Attachment 193932 Details for
Bug 41920
Limit number of concurrent reports that can be run simultaneously for an instance of Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41920: Limit number of concurrent reports that can be run simultaneously for an instance of Koha
2694c90.patch (text/plain), 6.36 KB, created by
Kyle M Hall (khall)
on 2026-02-25 18:06:46 UTC
(
hide
)
Description:
Bug 41920: Limit number of concurrent reports that can be run simultaneously for an instance of Koha
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2026-02-25 18:06:46 UTC
Size:
6.36 KB
patch
obsolete
>From 2694c901ef70d06db149df379f0ecb351765ff54 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 25 Feb 2026 13:05:03 -0500 >Subject: [PATCH] Bug 41920: Limit number of concurrent reports that can be run > simultaneously for an instance of Koha > >As a continuation of bug 41919, we should limit the total number of simultaneous reports that can be run at a time. > >Test Plan: >1) Set total_running_reports_per_instance_limit to 2 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 >5) Note the first two continue to run, but the last one gives an error > that you have too many reports running simultaneously! >--- > debian/templates/koha-conf-site.xml.in | 1 + > etc/koha-conf.xml | 1 + > .../modules/reports/guided_reports_start.tt | 2 ++ > reports/guided_reports.pl | 27 +++++++++++++++---- > 4 files changed, 26 insertions(+), 5 deletions(-) > >diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in >index 874a78668de..7f9bc6c469a 100644 >--- a/debian/templates/koha-conf-site.xml.in >+++ b/debian/templates/koha-conf-site.xml.in >@@ -343,6 +343,7 @@ __END_SRU_PUBLICSERVER__ > <!-- SQL report limits, 0 means the feature is disabled --> > <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit> > <total_running_reports_per_user_limit>0</total_running_reports_per_user_limit> >+ <total_running_reports_per_instance_limit>0</total_running_reports_per_instance_limit> > > <!-- Configuration for X-Forwarded-For --> > <!-- >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index d792bac050a..d4538212e3d 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -160,6 +160,7 @@ > <!-- SQL report limits, 0 means the feature is disabled --> > <duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit> > <total_running_reports_per_user_limit>0</total_running_reports_per_user_limit> >+ <total_running_reports_per_instance_limit>0</total_running_reports_per_instance_limit> > > <!-- Configuration for X-Forwarded-For --> > <!-- >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 55efe378ce9..3bd9affefa6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -1621,6 +1621,8 @@ > This report is already running. Please wait for it to finish before running it again. > [% ELSIF ( error.total_running_reports_per_user_limit_exceeded ) %] > You have too many reports running at the moment. Please wait for some of them to finish before running this report again. >+ [% ELSIF ( total_running_reports_per_instance_limit_exceeded ) %] >+ There are too many total reports running at the moment. Please wait for some of them to finish before running this report again. > [% ELSIF ( error.sqlerr ) %] > This report contains the SQL keyword <strong>[% error.sqlerr | html %]</strong>.<br /> > Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.<br /> >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 564bcd7dc89..248f85dea1a 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -802,15 +802,27 @@ if ( $op eq 'run' ) { > : 0; > > # Determine if the user is running too many reports in total >- my @total_running_report_ids; >+ my @total_running_for_user_report_ids; > my $total_running_reports_per_user_limit = C4::Context->config('total_running_reports_per_user_limit'); > if ( $total_running_reports_per_user_limit && C4::Context->userenv ) { > my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; >- @total_running_report_ids = Koha::Reports->running( { user_id => $user_id } ); >+ @total_running_for_user_report_ids = Koha::Reports->running( { user_id => $user_id } ); > } > my $total_running_reports_per_user_limit_exceeded = > $total_running_reports_per_user_limit >- ? scalar(@total_running_report_ids) >= $total_running_reports_per_user_limit >+ ? scalar(@total_running_for_user_report_ids) >= $total_running_reports_per_user_limit >+ : 0; >+ >+ # Determine if the Koha instance is running too many reports in total >+ my @total_running_for_instance_report_ids; >+ my $total_running_reports_per_instance_limit = C4::Context->config('total_running_reports_per_instance_limit'); >+ if ( $total_running_reports_per_instance_limit && C4::Context->instanceenv ) { >+ my $instance_id = C4::Context->instanceenv ? C4::Context->instanceenv->{number} : undef; >+ @total_running_for_instance_report_ids = Koha::Reports->running(); >+ } >+ my $total_running_reports_per_instance_limit_exceeded = >+ $total_running_reports_per_instance_limit >+ ? scalar(@total_running_for_instance_report_ids) >= $total_running_reports_per_instance_limit > : 0; > > # offset algorithm >@@ -1011,8 +1023,13 @@ if ( $op eq 'run' ) { > ? { duplicate_running_report_ids => \@duplicate_running_report_ids } > : (), > $total_running_reports_per_user_limit_exceeded >- ? { total_running_reports_per_user_limit_exceeded => \@total_running_report_ids } >- : () >+ ? { total_running_reports_per_user_limit_exceeded => \@total_running_for_user_report_ids } >+ : (), >+ $total_running_reports_per_instance_limit_exceeded >+ ? { >+ total_running_reports_per_instance_limit_exceeded => \@total_running_for_instance_report_ids >+ } >+ : (), > ], > 'sql_params' => \@sql_params, > 'param_names' => \@param_names, >-- >2.50.1 (Apple Git-155) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41920
:
193930
| 193932