[Koha-bugs] [Bug 34508] New: MARC modification templates have poor results when working with multiple of a field

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Aug 9 18:20:05 CEST 2023


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

            Bug ID: 34508
           Summary: MARC modification templates have poor results when
                    working with multiple of a field
 Change sponsored?: ---
           Product: Koha
           Version: 22.11
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Cataloging
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: ephetteplace at cca.edu
        QA Contact: testopia at bugs.koha-community.org
                CC: m.de.rooy at rijksmuseum.nl

Created attachment 154334
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=154334&action=edit
minimal example record

MARC modification templates "copy and replace" actions struggle to modify
records in an expected manner when there are multiple of the field being
modified. There are at least two unexpected results:

- a "copy and replace" on the "1st" of two fields results in the first field's
modified subfield being copied to the second
- using an "if" condition with either the "1st" or "all" fields also causes the
first field's modified subfield to overwrite the second's subfield, even if the
second does not meet the if condition

I've attached a minimal MARC record with two 856 fields. The goal of a
modification template should be to modify only the first "example.com" ‡u
subfield while leaving the second untouched. However, both of these
modification templates result in the second 856‡u being a copy of the first.

1) Copy and replace 1st field 856$u to 856$u using RegEx
s/^http?s://example\.com/https://proxy.cca.edu/?url=https://example.com/

2) Copy and replace field 856$u to 856$u using RegEx
s/^http?s://example\.com/https://proxy.cca.edu/?url=https://example.com/ if
856$u matches RegEx m/https?://example\.com.*/

Original record:
245 _ _ ‡aTest record for MARC modification
856 4 0 ‡uhttps://example.com‡yProxy link
856 4 0 ‡uhttps://cca.edu‡yRetain link

Expected outcome:
245 _ _ ‡aTest record for MARC modification
856 4 0 ‡uhttps://proxy.cca.edu/?url=https://example.com‡yProxy link
856 4 0 ‡uhttps://cca.edu‡yRetain link

Actual outcome:
245 _ _ ‡aTest record for MARC modification
856 4 0 ‡uhttps://proxy.cca.edu/?url=https://example.com‡yProxy link
856 4 0 ‡uhttps://proxy.cca.edu/?url=https://example.com‡yRetain link

Note that the second field's ‡y subfield is untouched. For template #1, I
expect the second field not to be modified because it specifies only the "1st"
MARC field. For template #2, I expect the second field not to be modified
because it does not match the if condition. In BOTH templates, the regex
substitution should not affect the second field, because it does not match the
pattern.

There was a thread on the Koha listserv between myself and Caroline Cyr La Rose
from August 4th to August 9th, 2023 that may provide helpful details.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list