Bug 24480: (follow-up) Shift new fields into array and add after all are copied
authorNick Clemens <nick@bywatersolutions.com>
Fri, 15 Sep 2023 19:59:57 +0000 (19:59 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 3 Nov 2023 15:04:34 +0000 (12:04 -0300)
commit498f0dfeccacb38fbc0b3ccbc6c47e769f7f8518
treec069df9ee42a08c3f8a68878ed198883394f21d2
parent48fd8d1900f23d33c2e7aa5f3a9f10c21cafdb54
Bug 24480: (follow-up) Shift new fields into array and add after all are copied

The updated code removed the pushing of fields to an array - this caused a bug.
When multiple fields were copied and replaced and there were more fields added than existed originally we were adding the new field to the end, then removing the first occurence of the original field. If we tried to move 2 650 fields to 651 and the record had no 651 we would:
- Delete the first 651, there were none, so nothing happened
- Take the first 650, add it to the end of the 651 group (there were none, so it became the first 651)
- Delete the first 651, which was the field we just copied
- Take the second 650 and add it to the end of the 651 group (whihc had none, because we deleted it)

I re-add the line, but do as suggesed by Phil and reverse the order (unshift vs push)

To test:
1 - Apply other patches
2 - prove -v t/SimpleMARC.t
3 - It fails
4 - Apply this patch
5 - prove -v t/SimpleMARC.t
6 - It still fails, but more tests pass (there's another patch to follow)

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/SimpleMARC.pm