Bugzilla – Attachment 187538 Details for
Bug 32950
MARC modification template moving subfield can lose values for repeatable fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32950: (follow-up) Fix copy_field regression for cross-field operations
Bug-32950-follow-up-Fix-copyfield-regression-for-c.patch (text/plain), 3.16 KB, created by
Martin Renvoize (ashimema)
on 2025-10-07 16:57:13 UTC
(
hide
)
Description:
Bug 32950: (follow-up) Fix copy_field regression for cross-field operations
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-10-07 16:57:13 UTC
Size:
3.16 KB
patch
obsolete
>From 3665b9efd29ca33c9039ef9b9f2564ea5382d0bb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 7 Oct 2025 17:51:53 +0100 >Subject: [PATCH] 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 <martin.renvoize@openfifth.co.uk> >--- > Koha/SimpleMARC.pm | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > >diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm >index d03a7fbaf1b..1b188e7b983 100644 >--- a/Koha/SimpleMARC.pm >+++ b/Koha/SimpleMARC.pm >@@ -674,9 +674,10 @@ sub _copy_move_subfield { > > # Find which source fields actually have the subfield to determine target field numbers > my @target_field_numbers; >- if ( $fromFieldName eq $toFieldName && @values ) { >+ if ( $fromFieldName eq $toFieldName && $fromSubfieldName ne $toSubfieldName && @values ) { > >- # For same-field operations, find fields that have the source subfield >+ # For same-field operations where subfields differ, find fields that have the source subfield >+ # This prevents overwriting target subfields in fields that don't have the source subfield > @target_field_numbers = > @{ field_exists( { record => $record, field => $fromFieldName, subfield => $fromSubfieldName } ) }; > if (@$field_numbers) { >@@ -694,7 +695,9 @@ sub _copy_move_subfield { > subfield => $toSubfieldName, > values => \@values, > dont_erase => $dont_erase, >- field_numbers => @target_field_numbers ? \@target_field_numbers : $field_numbers >+ field_numbers => @target_field_numbers >+ ? \@target_field_numbers >+ : ( $fromFieldName eq $toFieldName ? $field_numbers : [] ) > } > ); > >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32950
:
146586
|
186781
|
186782
|
187184
|
187185
|
187186
|
187187
|
187450
|
187451
|
187452
| 187538