From 6b846e327571c205ac162c59bd1702e4f95cbb8c 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 Content-Type: text/plain; charset=utf-8 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 --- 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 6675475602..66d91e41a9 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1992,11 +1992,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} //= []; @@ -2017,6 +2016,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 f83851fcd2..e7f4aa1fd2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1299,7 +1299,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