From 84b06293438cf170ff46f7327ad9e55fe30575f6 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 18 Dec 2024 12:09:27 -0100 Subject: [PATCH] Bug 38528: [ALTERNATIVE] Update empty field value logic prepare_cgi_additional_field_values needs to consider a field value as empty, because a MARC get field will always be submitted empty, and then picked up and handled by set_additional_fields accordingly. But because we don't want to polute the database with tons of empty additional fields if many empty repeatable fields were submitted in the UI, the check for empty value still happens, but only after the MARC get check has happen, not before. --- Koha/Object/Mixin/AdditionalFields.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm index b69d461252f..086b45683f0 100644 --- a/Koha/Object/Mixin/AdditionalFields.pm +++ b/Koha/Object/Mixin/AdditionalFields.pm @@ -77,7 +77,7 @@ sub set_additional_fields { } } - if (defined $value) { + if (defined $value && $value ne '') { my $field_value = Koha::AdditionalFieldValue->new({ field_id => $additional_field->{id}, record_id => $self->id, @@ -113,7 +113,7 @@ sub prepare_cgi_additional_field_values { push @additional_fields, { id => $field->id, value => $value, - } if defined $value && $value ne ''; + } if defined $value; } } -- 2.39.5