From 8fc876a731a819d2c761d7cbb7bae9d8ffae240b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 25 Jun 2021 07:45:32 +0000 Subject: [PATCH] Bug 28384: (follow-up) TransformMarcToKohaOneField should allow zeroes Content-Type: text/plain; charset=utf-8 Until now, the test did not pass false values like '0' or ''. But we should pass '0' and not ''. Note that the test for control fields is a bit theoretical since we dont have control fields bound to Koha fields currently. The adjusted unit test in the former patch should now pass. Test plan: Run TransformMarcToKoha.t Signed-off-by: Marcel de Rooy Since this change theoretically has a larger impact, I also tested the cataloguing editor, item editor. And run quite a few tests referring to AddBiblio or ModBiblio. --- C4/Biblio.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 8aeef65c96..242dd90057 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2422,9 +2422,10 @@ sub TransformMarcToKohaOneField { my $sub = $fldhash->{tagsubfield}; foreach my $fld ( $marc->field($tag) ) { if( $sub eq '@' || $fld->is_control_field ) { - push @rv, $fld->data if $fld->data; + my $data = $fld->data; + push @rv, $data if defined $data && $data ne ''; } else { - push @rv, grep { $_ } $fld->subfield($sub); + push @rv, grep { defined $_ && $_ ne '' } $fld->subfield($sub); } } } -- 2.20.1