From f065c95e74f4a79c79a1b4ba41cfc4bc8cd2f62a Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Fri, 14 Feb 2020 19:50:39 +0000 Subject: [PATCH] Bug 17510: enable use of subfield 0 in MMT actions When adding MARC modification template (MMT) actions, if a subfield value of 0 (zero) is entered it will not show up in the action's description upon saving. Also, if you try to modify an authority or biblio record using actions that refer to subfield 0 the procedure will fail. This patch fixes that. Test plan: 0) Create a MARC modification template and add some actions to it, ideally testing all action types (Delete/Add new/Update existing or add new/Move/Copy/Copy and replace); make sure you input a 0 (integer zero) in the text box for the subfield value(s). 1) As you save each action, observe that subfield 0 ($0) is missing from the action description. 2) Home > Tools > Batch record modification: try to modify a biblio- graphic record using the modification template you just created. Observe that you get an error in the system logs if you click on 'Show MARC' or 'Modify selected records'. 3) Apply the patch. 4) Repeat steps 0-2. The subfield value ($0) should be displayed in the action description and the Batch record modification should work without problems. Signed-off-by: Lisette Scheer Signed-off-by: Martin Renvoize --- Koha/SimpleMARC.pm | 4 ++-- .../prog/en/modules/tools/marc_modification_templates.tt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm index 5a916bdb03..cb92bff91a 100644 --- a/Koha/SimpleMARC.pm +++ b/Koha/SimpleMARC.pm @@ -164,7 +164,7 @@ sub update_field { if ( ! ( $record && $fieldName ) ) { return; } - if ( not $subfieldName or $subfieldName eq '' ) { + if ( not defined $subfieldName or $subfieldName eq '' ) { # FIXME I'm not sure the actual implementation is correct. die "This action is not implemented yet"; #_update_field({ record => $record, field => $fieldName, values => \@values }); @@ -296,7 +296,7 @@ sub read_field { my $subfieldName = $params->{subfield}; my $field_numbers = $params->{field_numbers} // []; - if ( not $subfieldName or $subfieldName eq '' ) { + if ( not defined $subfieldName or $subfieldName eq '' ) { _read_field({ record => $record, field => $fieldName, field_numbers => $field_numbers }); } else { _read_subfield({ record => $record, field => $fieldName, subfield => $subfieldName, field_numbers => $field_numbers }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt index 37477c73b6..9098bda200 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt @@ -133,14 +133,14 @@ field - [% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield | html %][% END %] + [% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield.length ) %]$[% ActionsLoo.from_subfield | html %][% END %] [% IF ( ActionsLoo.field_value ) %] with value [% ActionsLoo.field_value | html %] [% END %] [% IF ( ActionsLoo.to_field ) %] - to [% ActionsLoo.to_field | html %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield | html %][% END %] + to [% ActionsLoo.to_field | html %][% IF ( ActionsLoo.to_subfield.length ) %]$[% ActionsLoo.to_subfield | html %][% END %] [% IF ( ActionsLoo.to_regex_search ) %] using RegEx s/[% ActionsLoo.to_regex_search | html %]/[% ActionsLoo.to_regex_replace | html %]/[% ActionsLoo.to_regex_modifiers | html %] @@ -151,7 +151,7 @@ [% IF ( ActionsLoo.conditional_if ) %] if [% END %] [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %] - [% ActionsLoo.conditional_field | html %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield | html %][% END %] + [% ActionsLoo.conditional_field | html %][% IF ( ActionsLoo.conditional_subfield.length ) %]$[% ActionsLoo.conditional_subfield | html %][% END %] [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %] [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %] -- 2.39.5