From 757b59ca4c74d4f09f996d3b8fa5c3f7a49d393a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 13 Feb 2020 14:35:42 +0000 Subject: [PATCH] Bug 21800: Check the correct framework for the repeatable tag This depends on the framework parameter. Which should be added back to the call in C4::Items. Test plan: [1] Mark in Default framework one subfield A repeatable and B not repeatable. Go to item editor. (Work on a biblio in Default framework.) Check saving and reopening these subfields with VAL1 | VAL2. Subfield A should be cloned, B should be glued as entered. [2] Mark in another Framework A not repeatable and B repeatable. Change framework for this biblio. Go to item editor again. Reopen item. Behavior subfields in reverse? Signed-off-by: Marcel de Rooy Signed-off-by: Ere Maijala Signed-off-by: Katrin Fischer --- C4/Biblio.pm | 22 +++++++++++++++++----- C4/Items.pm | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 7922fa4409..7c7b900adc 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1998,11 +1998,10 @@ sub TransformKohaToMarc { my $tagsubfield = $fld->{tagsubfield}; next if !$tagfield; - # BZ 21800: split value if field is repeatable; NOTE that this also - # depends on the Default framework. - my @values = $params->{no_split} || !$fld->{repeatable} - ? ( $value ) - : split(/\s?\|\s?/, $value, -1); + # BZ 21800: split value if field is repeatable. + my @values = _check_split($params, $fld, $value) + ? split(/\s?\|\s?/, $value, -1) + : ( $value ); foreach my $value ( @values ) { next if $value eq ''; $tag_hr->{$tagfield} //= []; @@ -2023,6 +2022,19 @@ sub TransformKohaToMarc { return $record; } +sub _check_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} if !$params->{framework}; + + # here we need to check the specific framework + my $mss = Koha::MarcSubfieldStructures->find( $params->{framework}, $fld->{tagfield}, $fld->{tagsubfield} ); + return 1 if $mss && $mss->repeatable; +} + =head2 PrepHostMarcField $hostfield = PrepHostMarcField ( $hostbiblionumber,$hostitemnumber,$marcflavour ) diff --git a/C4/Items.pm b/C4/Items.pm index 8ed1c5efed..c91d150da2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1298,7 +1298,7 @@ sub Item2Marc { } keys %{ $itemrecord } }; my $framework = C4::Biblio::GetFrameworkCode( $biblionumber ); - my $itemmarc = C4::Biblio::TransformKohaToMarc( $mungeditem ); # Bug 21774: no_split parameter removed to allow cloned subfields + my $itemmarc = C4::Biblio::TransformKohaToMarc( $mungeditem, { framework => $framework } ); my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber", $framework, ); -- 2.11.0