From 2dd19840449beadd1f1752bd8cc18f0163f7f8a4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 22 Oct 2020 12:36:13 +0000 Subject: [PATCH] Bug 26784: Silence warns about comparing undefined values for MARC modification templates This patch simply checks if conditionals are defined before comparing We don't need to check actions because you cannot save an action without an action :-) To test: 1 - Define several actions for a MARC modification template 2 - Ensure you have actions with no conditionals 3 - Tail the intranet logs 4 - Browse to Tools->MARC modification templates 5 - Click 'Edit actions' for the template you setup above 6 - Note warns like: [2020/10/22 12:30:18] [WARN] Use of uninitialized value in string eq at /kohadevbox/koha/tools/marc_modification_templates.pl line 127. 7 - Apply patch 8 - Restart all the things 9 - Edit actions again and note no more warns Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- tools/marc_modification_templates.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/marc_modification_templates.pl b/tools/marc_modification_templates.pl index 27ace821e8..69bea401d2 100755 --- a/tools/marc_modification_templates.pl +++ b/tools/marc_modification_templates.pl @@ -121,13 +121,17 @@ foreach my $action ( @actions ) { $action->{'action_copy_field'} = ( $action->{'action'} eq 'copy_field' ); $action->{'action_copy_and_replace_field'} = ( $action->{'action'} eq 'copy_and_replace_field' ); - $action->{'conditional_if'} = ( $action->{'conditional'} eq 'if' ); - $action->{'conditional_unless'} = ( $action->{'conditional'} eq 'unless' ); - - $action->{'conditional_comparison_exists'} = ( $action->{'conditional_comparison'} eq 'exists' ); - $action->{'conditional_comparison_not_exists'} = ( $action->{'conditional_comparison'} eq 'not_exists' ); - $action->{'conditional_comparison_equals'} = ( $action->{'conditional_comparison'} eq 'equals' ); - $action->{'conditional_comparison_not_equals'} = ( $action->{'conditional_comparison'} eq 'not_equals' ); + if( defined $action->{'conditional'} ){ + $action->{'conditional_if'} = ( $action->{'conditional'} eq 'if' ); + $action->{'conditional_unless'} = ( $action->{'conditional'} eq 'unless' ); + } + + if( defined $action->{'conditional_comparison'} ){ + $action->{'conditional_comparison_exists'} = ( $action->{'conditional_comparison'} eq 'exists' ); + $action->{'conditional_comparison_not_exists'} = ( $action->{'conditional_comparison'} eq 'not_exists' ); + $action->{'conditional_comparison_equals'} = ( $action->{'conditional_comparison'} eq 'equals' ); + $action->{'conditional_comparison_not_equals'} = ( $action->{'conditional_comparison'} eq 'not_equals' ); + } } $template->param( -- 2.39.5