Bugzilla – Attachment 193930 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
26b8991.patch (text/plain), 6.75 KB, created by
Kyle M Hall (khall)
on 2026-02-25 17:43:26 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 17:43:26 UTC
Size:
6.75 KB
patch
obsolete
>From 26b899152bbbd79523aa2d6bf3fa6c4a5127ae71 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 25 Feb 2026 12:30:24 -0500 >Subject: [PATCH] Bug 41920: Limit number of concurrent reports that can be run > simultaneously for an instance of Koha > >Building on bug 41918, it would be good to limit the number of reports a given user can run at a time. >This control should be conf file based as it is tied to the server resources provided by whoever administers the server. > >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 >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 | 33 ++++++++++++++++--- > 4 files changed, 32 insertions(+), 5 deletions(-) > >diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in >index b51ff2bdb2f..874a78668de 100644 >--- a/debian/templates/koha-conf-site.xml.in >+++ b/debian/templates/koha-conf-site.xml.in >@@ -342,6 +342,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> > > <!-- Configuration for X-Forwarded-For --> > <!-- >diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml >index 21ad4f5c380..d792bac050a 100644 >--- a/etc/koha-conf.xml >+++ b/etc/koha-conf.xml >@@ -159,6 +159,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> > > <!-- 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 95491ab9751..55efe378ce9 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 >@@ -1619,6 +1619,8 @@ > [% FOREACH error IN errors %] > [% IF ( error.duplicate_running_report_ids ) %] > 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 ( 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 0da977eaa3f..564bcd7dc89 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -789,12 +789,29 @@ if ( $op eq 'run' ) { > my $template_id = $input->param('template'); > my $want_full_chart = $input->param('want_full_chart') || 0; > >+ # Determine if the user is running this report too many times > my @duplicate_running_report_ids; > my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit'); > if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) { > my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; > @duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } ); > } >+ my $duplicate_running_reports_per_user_limit_exceeded = >+ $duplicate_running_reports_per_user_limit >+ ? scalar(@duplicate_running_report_ids) >= $duplicate_running_reports_per_user_limit >+ : 0; >+ >+ # Determine if the user is running too many reports in total >+ my @total_running_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 } ); >+ } >+ 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 >+ : 0; > > # offset algorithm > if ( $input->param('page') ) { >@@ -980,8 +997,7 @@ if ( $op eq 'run' ) { > 'id' => $report_id, > 'template_id' => $template_id, > ); >- } elsif ( $duplicate_running_reports_per_user_limit >- && ( scalar @duplicate_running_report_ids >= $duplicate_running_reports_per_user_limit ) ) >+ } elsif ( $duplicate_running_reports_per_user_limit_exceeded || $total_running_reports_per_user_limit_exceeded ) > { > $template->param( > 'sql' => $sql, >@@ -990,9 +1006,16 @@ if ( $op eq 'run' ) { > 'execute' => 1, > 'name' => $name, > 'notes' => $notes, >- 'errors' => [ { duplicate_running_report_ids => \@duplicate_running_report_ids } ], >- 'sql_params' => \@sql_params, >- 'param_names' => \@param_names, >+ 'errors' => [ >+ $duplicate_running_reports_per_user_limit_exceeded >+ ? { 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 } >+ : () >+ ], >+ 'sql_params' => \@sql_params, >+ 'param_names' => \@param_names, > ); > } else { > my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params ); >-- >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