From 58cbb8f450a3fad0af118a326d0202fd2fdb4359 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 (cherry picked from commit 2eba689a5a5db2ac6a747c927d6daf01e7c64002) Signed-off-by: Martin Renvoize (cherry picked from commit 4945626e32cf5387694485261f26a3f18588704c) Signed-off-by: Matt Blenkinsop --- 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 ca8baa64d9..abc8386f77 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 ); @@ -230,7 +230,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 d339c6cb40..1d638452f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -277,7 +277,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