Bug 25081 - new item for a received issue is (stochastically) not created
Summary: new item for a received issue is (stochastically) not created
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Serials (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major (vote)
Assignee: Janusz Kaczmarek
QA Contact: Testopia
URL:
Keywords:
Depends on: 23435
Blocks:
  Show dependency treegraph
 
Reported: 2020-04-07 20:22 UTC by Janusz Kaczmarek
Modified: 2020-11-30 21:44 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.06


Attachments
Bug 25081 - new item for a received issue is (stochastically) not created (3.27 KB, patch)
2020-04-07 20:36 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 25081 - new item for a received issue is (stochastically) not created (3.32 KB, patch)
2020-04-07 21:03 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 25081: Fix creation of new item for a received issue (3.38 KB, patch)
2020-04-08 09:47 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25081: Fix wrong comment (834 bytes, patch)
2020-04-08 09:47 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Janusz Kaczmarek 2020-04-07 20:22:55 UTC
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.

So, to reproduce, 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.   (Sometimes it occurs also while receiving back issues). 

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.

A patch will follow.
Comment 1 Janusz Kaczmarek 2020-04-07 20:36:43 UTC
Created attachment 102527 [details] [review]
Bug 25081 - new item for a received issue is (stochastically) not created

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.
Comment 2 Aleisha Amohia 2020-04-07 21:03:47 UTC
Created attachment 102528 [details] [review]
Bug 25081 - new item for a received issue is (stochastically) not created

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>
Comment 3 Jonathan Druart 2020-04-08 09:47:44 UTC
Created attachment 102544 [details] [review]
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 <aleishaamohia@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Jonathan Druart 2020-04-08 09:47:47 UTC
Created attachment 102545 [details] [review]
Bug 25081: Fix wrong comment

Not directly related to previous patch, coming from 23435.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 5 Martin Renvoize 2020-04-08 10:55:44 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 6 Janusz Kaczmarek 2020-04-25 18:57:56 UTC
(In reply to Martin Renvoize from comment #5)
> Nice work everyone!
> 
> Pushed to master for 20.05

I would suggest pushing it to 19.11.XX as well since 19.11 is affected.
Comment 7 Joy Nelson 2020-05-04 20:58:09 UTC
backported to 19.11.x for 19.11.06
Comment 8 Lucas Gass 2020-05-11 22:25:22 UTC
missing dependencies for 19.05.x, no backport