From 073714f6e60bfa2a8b4b079ef86747ca04c86c99 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 15 Apr 2020 13:46:50 +0000 Subject: [PATCH] Bug 24715: (QA follow-up) Remove $mss2 tric Content-Type: text/plain; charset=utf-8 As requested by QA, removing the $mss2 variable. This may lead to repeated calls to the cache. --- C4/Biblio.pm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 01f6d20e50..dd628f830d 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1991,9 +1991,7 @@ sub TransformKohaToMarc { # In the next call we use the Default framework, since it is considered # authoritative for Koha to Marc mappings. my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework - my $mss2; # belongs to $params->{framework} only filled when needed my $tag_hr = {}; - my $need_split; while ( my ($kohafield, $value) = each %$hash ) { foreach my $fld ( @{ $mss->{$kohafield} } ) { my $tagfield = $fld->{tagfield}; @@ -2001,7 +1999,7 @@ sub TransformKohaToMarc { next if !$tagfield; # BZ 21800: split value if field is repeatable. - ( $need_split, $mss2 ) = _check_split($params, $mss2, $fld, $value); + my $need_split = _check_split($params, $fld, $value); my @values = $need_split ? split(/\s?\|\s?/, $value, -1) : ( $value ); @@ -2028,23 +2026,21 @@ sub TransformKohaToMarc { sub _check_split { # Checks if $value must be split; may consult passed framework # Returns 0|1, and framework hash if consulted - my ($params, $mss2, $fld, $value) = @_; - return (0, $mss2) if index($value,'|') == -1; # nothing to worry about - return (0, $mss2) if $params->{no_split}; + my ($params, $fld, $value) = @_; + return if index($value,'|') == -1; # nothing to worry about + return if $params->{no_split}; # if we did not get a specific framework, check default in $mss - return ( $fld->{repeatable}, $mss2) if !$params->{framework}; + return $fld->{repeatable} if !$params->{framework}; # here we need to check the specific framework - if(!$mss2) { - $mss2 = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 }); - } - foreach my $fld2 ( @{ $mss2->{ $fld->{kohafield} } } ) { + my $mss = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 }); + foreach my $fld2 ( @{ $mss->{ $fld->{kohafield} } } ) { next if $fld2->{tagfield} ne $fld->{tagfield}; next if $fld2->{tagsubfield} ne $fld->{tagsubfield}; - return (1, $mss2) if $fld2->{repeatable}; + return 1 if $fld2->{repeatable}; } - return (0, $mss2); + return; } =head2 PrepHostMarcField -- 2.11.0