https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32950

--- Comment #15 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 187538
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187538&action=edit
Bug 32950: (follow-up) Fix copy_field regression for cross-field operations

The bug 32950 fix introduced a regression that broke copy_field operations
when copying between different fields or when copying a subfield to itself
within the same field.

The original fix correctly handled moving subfields between different
subfields within the same field (e.g., 020$z to 020$a) by using
field_exists() to identify which fields have the source subfield.

However, this logic was applied too broadly:

1. Cross-field operations (e.g., 650$a to 651$a): The fix passed source
   field_numbers to _update_subfield for the target field, causing it to
   look for non-existent target field positions. This resulted in
   insert_fields_ordered creating new fields out of order.

2. Same-field, same-subfield operations (e.g., 952$d to 952$d): The fix
   prevented copying to fields that didn't have the source subfield, but
   the original behavior was correct for duplicating a subfield to itself.

This patch restricts the bug 32950 logic to only apply when:
- Source and target fields are the same AND
- Source and target subfields are different

Additionally, it ensures field_numbers are not passed to _update_subfield
when copying between different fields.

Test plan:
1. Run prove t/SimpleMARC.t
2. All tests should pass, including:
   - Cross-field copy operations (650$a to 651$a)
   - Same-field, different-subfield operations (020$z to 020$a)
   - Same-field, same-subfield operations (952$d to 952$d)

Signed-off-by: Martin Renvoize <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to