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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-06-28 14:14:51 +00:00 committed by Tomas Cohen Arazi
parent 252753f84f
commit 2eba689a5a
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 3 additions and 3 deletions

View file

@ -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;

View file

@ -286,7 +286,7 @@
<label for="number_of_copies">Number of copies of this item to add: </label>
<input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
<input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) && CheckMultipleAdd(this.form.number_of_copies.value);" /> <a href="#" id="cancel_add_multiple" class="cancel">Cancel</a>
<div class="hint"><p>The barcode you enter will be incremented for each additional item.</p></div>
<div class="hint"><p>Maximum currently set to 1000. The barcode you enter will be incremented for each additional item.</p></div>
</fieldset>
<span id="savetemplate">