The Bug 23435 introduced the idea of multiple copies added while
receiving a new issue. Unfortunately, under some circumstances, it
causes no items being added at all. It occurs stochastically, only
under some conditions. But it is quite likely to happen while receiving
a supplemental issue.
The reason fot hist is that, in serials-edit.pl, line ca 292 and infra,
@num_copies is treated in the same way as @tags, while it should be
treated similarly to @bibnums. It will be obvious after examining the
content of parameters tag, subfield, field_value, ..., number_of_copies.
In other words, for every edited issue number_of_copies is a scalar.
Nota bene:
a) beter to initialize $countdistinct with zero;
b) note that in master, now, before applying the patch,
$itemhash{$item}->{'num_copies'} is treated once as a scalar
and in the next line--as an array:
$itemhash{$item}->{'num_copies'} //= 1;
for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'}[$index];){
TEST PLAN
=========
1. Have a subscription with the option "Create an item
record when receiving this serial" active and try to receive a
supplemental issue. Control that a new item under the biblio record
(usually) will not be created.
2. Apply the patch.
3. Repeat p. 1 -- a new item should be created.
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
#Rebuilding ALL the data for items into a hash
# parting them on $itemid.
my %itemhash;
- my $countdistinct;
+ my $countdistinct = 0;
my $range = scalar(@itemid);
for ( my $i = 0 ; $i < $range ; $i++ ) {
unless ( $itemhash{ $itemid[$i] } ) {
$itemhash{ $itemid[$i] }->{'serial'} = $newserial;
}
$itemhash{ $itemid[$i] }->{'bibnum'} = $bibnums[$countdistinct];
+ $itemhash{ $itemid[$i] }->{'num_copies'} = $num_copies[$countdistinct];
$countdistinct++;
}
push @{ $itemhash{ $itemid[$i] }->{'tags'} }, $tags[$i];
$field_values[$i];
push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i];
push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i];
- push @{ $itemhash{ $itemid[$i] }->{'num_copies'} }, $num_copies[$i];
}
foreach my $item ( keys %itemhash ) {
$itemhash{$item}->{'num_copies'} //= 1;
- for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'}[$index];){
+ for (my $copy = 0; $copy < $itemhash{$item}->{'num_copies'};){
# New Item