From 2eba689a5a5db2ac6a747c927d6daf01e7c64002 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 28 Jun 2023 14:14:51 +0000 Subject: [PATCH] Bug 34146: Do not allow multiple copies to crash server Currently hardcoded to 1000. Can be refined later. Let's first prevent this kind of accidents. Test plan: Add additem.pl. Edit the 1000 to 2. Restart all. Add 3 multiple copies. Notice that you got 2. Revert your code change. Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- cataloguing/additem.pl | 4 ++-- .../intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 4630eec0a4..2c9871280c 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -45,7 +45,7 @@ use Koha::Result::Boolean; use Encode qw( encode_utf8 ); use List::MoreUtils qw( any uniq ); -use List::Util qw( first ); +use List::Util qw( first min ); use MARC::File::XML; use MIME::Base64 qw( decode_base64url encode_base64url ); use Storable qw( freeze thaw ); @@ -238,7 +238,7 @@ if ($op eq "additem") { my $add_duplicate_submit = $input->param('add_duplicate_submit'); my $add_multiple_copies_submit = $input->param('add_multiple_copies_submit'); my $save_as_template_submit = $input->param('save_as_template_submit'); - my $number_of_copies = $input->param('number_of_copies'); + my $number_of_copies = min( scalar $input->param('number_of_copies'), 1000 ); # TODO refine hardcoded maximum? my @columns = Koha::Items->columns; my $item = Koha::Item->new; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 2401c4f3fb..4c349b37db 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -286,7 +286,7 @@ Cancel -

The barcode you enter will be incremented for each additional item.

+

Maximum currently set to 1000. The barcode you enter will be incremented for each additional item.

-- 2.39.5