Bug 41918: Add ability to disable or change limit via config xml

This commit add the option duplicate_running_reports_per_user_limit to
koha-conf.xml. If this option is empty or 0, the feature is disabled. If
this option is enabled, Koha will limit the number of times a given
report can be run of a single Koha user.

Test Plan:
1) Apply this patch
2) Set duplicate_running_reports_per_user_limit to 1, verify previous
   behavior is maintained
2) Set duplicate_running_reports_per_user_limit to 0, verify the feature
   is disabled
3) Set duplicate_running_reports_per_user_limit to 2, verify Koha limits
   the number of duplicates of the report to the number specified in duplicate_running_reports_per_user_limit

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>
This commit is contained in:
Kyle M Hall 2026-02-25 11:33:11 -05:00 committed by Lucas Gass
parent 7bd64b0f6f
commit 9d0d9715e8
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 11 additions and 2 deletions

View File

@ -345,6 +345,9 @@ __END_SRU_PUBLICSERVER__
<plack_max_requests>50</plack_max_requests>
<plack_workers>2</plack_workers>
<!-- SQL report limits, 0 means the feature is disabled -->
<duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
<!-- Configuration for X-Forwarded-For -->
<!-- Set enable_trusted_proxy_for_headers to 0 to never trust proxy headers, always use given REMOTE_ADDRESS -->
<!--

View File

@ -162,6 +162,9 @@
<plack_max_requests>50</plack_max_requests>
<plack_workers>2</plack_workers>
<!-- SQL report limits, 0 means the feature is disabled -->
<duplicate_running_reports_per_user_limit>0</duplicate_running_reports_per_user_limit>
<!-- Configuration for X-Forwarded-For -->
<!-- Set enable_trusted_proxy_for_headers to 0 to never trust proxy headers, always use given REMOTE_ADDRESS -->
<!--

View File

@ -825,7 +825,8 @@ if ( $op eq 'run' ) {
my $want_full_chart = $input->param('want_full_chart') || 0;
my @duplicate_running_report_ids;
if ( C4::Context->userenv ) {
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 } );
}
@ -1015,7 +1016,9 @@ if ( $op eq 'run' ) {
'id' => $report_id,
'template_id' => $template_id,
);
} elsif (@duplicate_running_report_ids) {
} elsif ( $duplicate_running_reports_per_user_limit
&& ( scalar @duplicate_running_report_ids >= $duplicate_running_reports_per_user_limit ) )
{
$template->param(
'sql' => $sql,
'original_sql' => $original_sql,