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".
Created attachment 89362 [details] [review] Bug 22571: Add tests
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
Created attachment 90683 [details] [review] Bug 22571: Add tests Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
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>
Created attachment 90685 [details] [review] Bug 22571: (follow up) fix Donald cut-&-paste error Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
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>
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>
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>
Nice work! Pushed to master for 19.11.00
Pushed to 19.05.x for 19.05.02
I just tested the original case in Koha 20.05.00, but wasn't successful: After 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..$/ I also tried the following action (omitting ^and $): 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.
(In reply to Michael Kuhn from comment #11) > I just tested the original case in Koha 20.05.00, but wasn't successful: > > After 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..$/ > > I also tried the following action (omitting ^and $): > > 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. Hi Michael, if a bug has already been 'released' please don't reopen but open a new bug and link to this one instead - bugzilla will email everyone on the linked bug too.