Bug 22571

Summary: MARC modification templates do not handle control fields in conditional
Product: Koha Reporter: Michael Kuhn <mik>
Component: ToolsAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: benjamin.r.philbrook, fridolin.somers, jonathan.druart, josef.moravec
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Who signed the patch off: Text to go in the release notes:
Version(s) released in:
19.11.00,19.05.02
Attachments: Bug 22571: Add tests
Bug 22571: Handle control fields in MMT for conditionals
Bug 22571: Add tests
Bug 22571: Handle control fields in MMT for conditionals
Bug 22571: (follow up) fix Donald cut-&-paste error
Bug 22571: Add tests
Bug 22571: Handle control fields in MMT for conditionals
Bug 22571: (follow up) fix Donald cut-&-paste error

Description Michael Kuhn 2019-03-24 19:48:56 UTC
After successfully creating a MARC modification template in Koha menu "Tools > Batch record modification" with the following action:

Add new field 041$a with value ger if 008 matches RegEx m/^...................................ger..$/

the action is run over a given record and Koha says that the bibliographic record has successfully been modified - but in fact nothing has changed, thus no new MARC 041$a is created.

According to Jonathan Druart (in mailinglist "Koha", 21.03.2019 17:12) this is a bug in Perl module "Koha::SimpleMARC::field_equals".
Comment 1 Jonathan Druart 2019-05-05 17:46:31 UTC
Created attachment 89362 [details] [review]
Bug 22571: Add tests
Comment 2 Jonathan Druart 2019-05-05 17:46:33 UTC
Created attachment 89363 [details] [review]
Bug 22571: Handle control fields in MMT for conditionals

Control fields are not handled correctly by Koha::SimpleMARC when
comparaison (with or without regex) is done.

Which means we did not support something like:
Do something if control field 008 equals or matches "a string"

Test plan:
Create a new MARC modification template and a new action, like:
Add new field 100$a with value "foo bar" if 008 (or any other control
fields) matches (or equals) a regex
Then use the record mofication tool and confirm that the new field is
create if the regex matches 008 of the bib record
Comment 3 M. Tompsett 2019-06-17 17:59:31 UTC
Created attachment 90683 [details] [review]
Bug 22571: Add tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 4 M. Tompsett 2019-06-17 17:59:33 UTC
Created attachment 90684 [details] [review]
Bug 22571: Handle control fields in MMT for conditionals

Control fields are not handled correctly by Koha::SimpleMARC when
comparaison (with or without regex) is done.

Which means we did not support something like:
Do something if control field 008 equals or matches "a string"

Test plan:
Create a new MARC modification template and a new action, like:
Add new field 100$a with value "foo bar" if 008 (or any other control
fields) matches (or equals) a regex
Then use the record mofication tool and confirm that the new field is
create if the regex matches 008 of the bib record

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 5 M. Tompsett 2019-06-17 17:59:36 UTC
Created attachment 90685 [details] [review]
Bug 22571: (follow up) fix Donald cut-&-paste error

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Comment 6 Nick Clemens 2019-06-21 11:30:25 UTC
Created attachment 90896 [details] [review]
Bug 22571: Add tests

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 7 Nick Clemens 2019-06-21 11:30:28 UTC
Created attachment 90897 [details] [review]
Bug 22571: Handle control fields in MMT for conditionals

Control fields are not handled correctly by Koha::SimpleMARC when
comparaison (with or without regex) is done.

Which means we did not support something like:
Do something if control field 008 equals or matches "a string"

Test plan:
Create a new MARC modification template and a new action, like:
Add new field 100$a with value "foo bar" if 008 (or any other control
fields) matches (or equals) a regex
Then use the record mofication tool and confirm that the new field is
create if the regex matches 008 of the bib record

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens 2019-06-21 11:30:31 UTC
Created attachment 90898 [details] [review]
Bug 22571: (follow up) fix Donald cut-&-paste error

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Martin Renvoize 2019-06-21 12:13:45 UTC
Nice work!

Pushed to master for 19.11.00
Comment 10 Fridolin SOMERS 2019-07-16 06:41:04 UTC
Pushed to 19.05.x for 19.05.02