From ac3918c07475dd2b8afe1ec35e9eafd3897cc5fd Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 6 May 2021 09:09:03 -0400 Subject: [PATCH] Bug 27837: Always pass permanent location from items editor if it was defined By always passing permenent location from the items editor, we can know if permanent location was defined in the framework. This means we can know if we should update permanent location independently of location even if permenent location has an empty value. --- C4/Biblio.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index f6c89f92e8..603d19e5a0 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2076,6 +2076,8 @@ sub TransformHtmlToXml { my ( $tags, $subfields, $values, $indicator, $ind_tag, $auth_type ) = @_; # NOTE: The parameter $ind_tag is NOT USED -- BZ 11247 + my ( $perm_loc_tag, $perm_loc_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.permanent_location" ); + my $xml = MARC::File::XML::header('UTF-8'); $xml .= "\n"; $auth_type = C4::Context->preference('marcflavour') unless $auth_type; @@ -2091,7 +2093,6 @@ sub TransformHtmlToXml { my $j = -1; my $close_last_tag; for ( my $i = 0 ; $i < @$tags ; $i++ ) { - if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and @$tags[$i] eq "100" and @$subfields[$i] eq "a" ) { # if we have a 100 field and it's values are not correct, skip them. @@ -2109,6 +2110,13 @@ sub TransformHtmlToXml { @$values[$i] =~ s/"/"/g; @$values[$i] =~ s/'/'/g; + my $skip = @$values[$i] eq q{}; + $skip = 0 + if $perm_loc_tag + && $perm_loc_subfield + && @$tags[$i] eq $perm_loc_tag + && @$subfields[$i] eq $perm_loc_subfield; + if ( ( @$tags[$i] ne $prevtag ) ) { $close_last_tag = 0; $j++ unless ( @$tags[$i] eq "" ); @@ -2118,7 +2126,7 @@ sub TransformHtmlToXml { if ( !$first ) { $xml .= "\n"; if ( ( @$tags[$i] && @$tags[$i] > 10 ) - && ( @$values[$i] ne "" ) ) { + && ( !$skip ) ) { $xml .= "\n"; $xml .= "@$values[$i]\n"; $first = 0; @@ -2127,7 +2135,7 @@ sub TransformHtmlToXml { $first = 1; } } else { - if ( @$values[$i] ne "" ) { + if ( !$skip ) { # leader if ( @$tags[$i] eq "000" ) { @@ -2147,8 +2155,7 @@ sub TransformHtmlToXml { } } } else { # @$tags[$i] eq $prevtag - if ( @$values[$i] eq "" ) { - } else { + if ( !$skip ) { if ($first) { my $str = ( $indicator->[$j] // q{} ) . ' '; # extra space prevents substr outside of string warn my $ind1 = _default_ind_to_space( substr( $str, 0, 1 ) ); -- 2.24.3 (Apple Git-128)