From bb527d54f598f91e4373282032fbc1ab9b0515d3 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Tue, 7 Apr 2020 22:23:20 +0200 Subject: [PATCH] Bug 25081: Fix creation of new item for a received issue 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 Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- serials/serials-edit.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index fd1b7bd31c..88445a92bc 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -294,7 +294,7 @@ if ( $op and $op eq 'serialchangestatus' ) { #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] } ) { @@ -308,6 +308,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $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]; @@ -316,7 +317,6 @@ if ( $op and $op eq 'serialchangestatus' ) { $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 ) { @@ -346,7 +346,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $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 -- 2.39.5