Bug 32950 - MARC modification template moving subfield can lose values for repeatable fields
Summary: MARC modification template moving subfield can lose values for repeatable fields
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: 21.11
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-13 15:48 UTC by Bernard
Modified: 2023-07-26 12:58 UTC (History)
2 users (show)

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


Attachments
mrc with multiple 020 fields including 020$z (3.47 KB, application/marc)
2023-02-13 15:48 UTC, Bernard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard 2023-02-13 15:48:06 UTC
Created attachment 146586 [details]
mrc with multiple 020 fields including 020$z

Moving one subfield to another fails for repeatable fields where the field to be moved doesn't exist in the first instance

1. Make marcmodtemplate as follows
a. Move every 020 z field to field 020 a 
2. Stage marc exchange file (attached) with following in 020 field (note only 7th and 8th have 020z and these are the ones we wish to move to subfield a)

=020  \\$a9781003182870$q(ebk)
=020  \\$a1003182879
=020  \\$a9781000407204$q(electronic bk. : EPUB)
=020  \\$a1000407209$q(electronic bk. : EPUB)
=020  \\$a9781000407167$q(electronic bk. : PDF)
=020  \\$a1000407160$q(electronic bk. : PDF)
=020  \\$z9781032023175$q(hbk.)
=020  \\$z9780367760380$q(pbk.)
3. view staged record and observe fields 020 subfield a fields have all gone and subfield z has not been moved, but its value removed:

020			_a
_q(ebk)
020			_a
020			_a
_q(electronic bk. : EPUB)
020			_a
_q(electronic bk. : EPUB)
020			_a
_q(electronic bk. : PDF)
020			_a
_q(electronic bk. : PDF)
020			_q(hbk.)
_a
020			_q(pbk.)
_a


Note, adding a conditional to marcmodtemplate "only do this if 020 z subfield exists makes no difference.
Comment 1 Bernard 2023-02-13 15:53:31 UTC
In case it helps, I believe the problem occurs at line 616 in Koha/SimpleMARC.pm

    if ( @$field_numbers ) {
        @values = map { $_ <= @values ? $values[ $_ - 1 ] : () } @$field_numbers;
    }

@values is empty after these lines have run.