Bug 18458: Fix subfields ordering when Merging authority records
authorJanusz Kaczmarek <januszop@gmail.com>
Sat, 25 Nov 2017 01:28:02 +0000 (02:28 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 19 Jan 2018 12:36:54 +0000 (13:36 +0100)
commitcdf608606fb35074acfe15d770fc36d395471bcb
tree48003d3bf78262a9958c071e04f8e4580e3a723d
parent93b3cbff26680ca94534604b04bd99edfa6911b1
Bug 18458: Fix subfields ordering when Merging authority records

While doing a merge, if a subfield(s) precedes the controlled subfields
(like $i before $a in 7XX, which comes before $a -- rare but will
become more and more usual) after merging will be moved to the end.
This is not right.

The patch (with AuthorityMergeMode == loose) make merge consider the
subfields order: all subfields which originally were found before
the first controlled subfield (e.g. $i before $a in 7XX / MARC 21)
will remain in the front, the rest of not controlled subfields that
should remain in the field will come after the subfields copied
from authority rec.

As a bonus, $9 will be placed at the end.

To test:
0) Have AuthorityMergeMode == loose;
1) Have some field in bibliorecord, controlled by an authority, with
extra subfield(s) (i.e. not present in authority rec.) placed at the
beginning of the field;
2) Open (not necessarily edit) and save the connected authority;
3) See that the extra subfieds were moved to the end of the field
   (and $9 is in the front);
4) Apply the patch;
5) Reorder subfields in biblio field;
6) Open (not necessarily edit) and save the connected authority;
7) See that the order has been conserved, additionally $9 the last
   subfield in the field.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended:
Moved field creation to its original place. Changed $9 handling. Simplified the following add_subfields for loop. Edited comments.
Restored the append_fields_ordered call (see comment6).

With this patch, the Merge.t test now passes.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 806ad212f5c5c765abd657de7891bc41ed24dfcf)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/AuthoritiesMarc.pm