[Bug 39909] New: Batch modification with regex does not work with control fields
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Bug ID: 39909 Summary: Batch modification with regex does not work with control fields Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: fridolin.somers@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl In MARC modification templates if you define a copy of a control field into another control field. The regexp part does not work. Because of : https://git.koha-community.org/Koha-community/Koha/src/commit/83f8ba4eeed5c3... -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |minor -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #1 from Fridolin Somers <fridolin.somers@biblibre.com> --- "control field" means field with tag number < 10 Like 003 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=28915 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Eric Phetteplace <ephetteplace@cca.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ephetteplace@cca.edu -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk CC| |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |CONFIRMED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- 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 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |26.11 Initiative type|--- |Feature Sponsorship status|--- |Unsponsored -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bernard.scaife@openfifth.co | |.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 John Vinke <jvinke@austinseminary.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Patch doesn't apply CC| |jvinke@austinseminary.edu --- Comment #3 from John Vinke <jvinke@austinseminary.edu> --- I tried testing this and the patch would not apply. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #205883|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208704 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208704&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 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- All rebased, sorry for the delay John Vinke, thanks for the interest. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|minor |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 John Vinke <jvinke@austinseminary.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #6 from John Vinke <jvinke@austinseminary.edu> --- As a cataloger, this makes me very happy. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 John Vinke <jvinke@austinseminary.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208704|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #7 from John Vinke <jvinke@austinseminary.edu> --- Created attachment 208735 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208735&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 <noreply@anthropic.com> Signed-off-by: John Vinke <jvinke@austinseminary.edu> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |andrew@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208735|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 --- Comment #8 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 209392 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209392&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 <noreply@anthropic.com> Signed-off-by: John Vinke <jvinke@austinseminary.edu> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39909 Eric Phetteplace <ephetteplace@cca.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|ephetteplace@cca.edu | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org