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

--- Comment #2 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 205883
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205883&action=edit
Bug 39909: Fix regex not applied when copying a control field

When using a MARC modification template to copy one control field
(tag < 010, e.g. 003, 001, 008) into another control field with a
regex transformation, the regex was silently ignored.

_copy_move_field() applied the regex by iterating over
$new_field->subfields, but control fields have no subfields - their
value lives in $field->data instead. The loop body therefore never
ran for control fields, so the regex substitution never happened
while the field copy/move itself succeeded silently.

Fixed by applying the regex to $new_field->data via
is_control_field(), mirroring the existing control field handling in
field_equals().

Test plan:
1. Go to Cataloguing > MARC modification templates and create a new
   template.
2. Add an action: Field 003, action "Copy field", to field 009, with
   a regular expression, e.g. search "^OSt" replace "TEST".
3. Save the template.
4. Go to Tools > Batch record modification.
5. Enter the biblionumber (or a list) of a record whose 003 value
   matches the search pattern above (or edit any record first to set
   003 to "OSt something"), pick the template just created, and run
   the modification.
6. Open the modified record and check field 009: before the fix, 009
   was created but contained an exact, unmodified copy of 003; after
   the fix, 009 reflects the regex substitution (e.g. starts with
   "TEST" instead of "OSt").
7. prove t/SimpleMARC.t

Co-Authored-By: Claude Sonnet 5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to