From 0e06409547984d1b5d66d2902bf7e38e02198d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Wed, 14 Apr 2021 15:07:58 +0300 Subject: [PATCH] Bug 20447: Return all Koha fields even if the value is empty The database columns are updated using the koha field values returned by this subroutine and if we don't return all of them (even the empty ones) the holdings table's database columns won't get emptied. --- Koha/Holding.pm | 6 +++--- t/db_dependent/Koha/Holding.t | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Koha/Holding.pm b/Koha/Holding.pm index e887e6adaf..b80a515607 100644 --- a/Koha/Holding.pm +++ b/Koha/Holding.pm @@ -321,13 +321,13 @@ sub marc_to_koha_fields { my $sub = $field->{tagsubfield}; foreach my $fld ($record->field($tag)) { if( $sub eq '@' || $fld->is_control_field ) { - push @values, $fld->data if $fld->data; + push @values, $fld->data; } else { - push @values, grep { $_ } $fld->subfield($sub); + push @values, $fld->subfield($sub); } } } - $result->{$column} = join(' | ', @values) if (@values); + $result->{$column} = scalar(@values) ? join(' | ', @values) : undef; } return $result; } diff --git a/t/db_dependent/Koha/Holding.t b/t/db_dependent/Koha/Holding.t index fd099345d8..765e5ce93d 100755 --- a/t/db_dependent/Koha/Holding.t +++ b/t/db_dependent/Koha/Holding.t @@ -139,6 +139,12 @@ subtest 'Koha::Holding tests' => sub { { holdingbranch => 'ABC', location => 'DEF', + ccode => undef, + indexes => undef, + public_note => undef, + callnumber => undef, + summary => undef, + supplements => undef, suppress => 1, holding_id => $new_holding->holding_id() }, -- 2.11.0