Bug 41138

Summary: Batch record modification via MARC modification template overwrites equal fields.
Product: Koha Reporter: int
Component: CatalogingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: m.de.rooy
Version: 25.05   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Crowdfunding goal: 0
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description int 2025-10-30 01:22:18 UTC
I want to batch correct a URL in the MARC-Data.
So I created a MARC modification templates as described in the manual (see the proxy URL example):
https://koha-community.org/manual/25.05/en/html/cataloging.html#marc-modification-templates 
I did
"Copy and replace" over "All" field(s) "856 u" to field "856 u" with Regex "s/deposit.d-nb.de/deposit.dnb.de/g"
if field "856 u" matches "m/deposit.d-nb.de/" RegEx

The fields in the original record look like this:
856 42 _u http://d-nb.info/1050788141/04
       _3Inhaltsverzeichnis
856 42 _u http://deposit.d-nb.de/cgi-bin/dokserv?id=4659369&prov=M&dok_var=1&dok_ext=htm
       _3Inhaltstext
856 42 _u http://www.perlentaucher.de/buch/barbara-sichtermann/ich-rauche-zigarren-und-glaube-nicht-an-g
       _3Rezension

After applying the template, I would expect that only the middle one gets modified.
Instead I get this:
856 42 _uhttp://deposit.dnb.de/cgi-bin/dokserv?id=4659369&prov=M&dok_var=1&dok_ext=htm
       _3Inhaltsverzeichnis
856 42 _uhttp://deposit.dnb.de/cgi-bin/dokserv?id=4659369&prov=M&dok_var=1&dok_ext=htm
       _3Inhaltstext
856 42 _uhttp://deposit.dnb.de/cgi-bin/dokserv?id=4659369&prov=M&dok_var=1&dok_ext=htm
       _3Rezension 

It doesn't matter if I do "All" field(s) or "1." field(s) in the template, the result is the same.
This is probably related to and maybe not the same as
Bug 28231 - MARC modification template "1st" vs "Every" bug?
and
Bug 34508 - MARC modification templates have poor results when working with multiple of a field

I think this bug is severe as it can go unnoticed and lead to data loss in a lot of records.
Unnoticed because if you only have one field everything looks good and only multiple equal fields get overwritten.