# 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 framewok
+ my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework
my $tag_hr = {};
while ( my ($kohafield, $value) = each %$hash ) {
foreach my $fld ( @{ $mss->{$kohafield} } ) {
}
sub _check_split {
+# Checks if $value must be split; may consult passed framework
my ($params, $fld, $value) = @_;
return if index($value,'|') == -1; # nothing to worry about
return if $params->{no_split};
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;
+ 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 if $fld2->{repeatable};
+ }
+ return;
}
=head2 PrepHostMarcField
};
subtest "Add tests for _check_split" => sub {
- plan tests => 7;
+ plan tests => 8;
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'a' })->delete;
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'a', kohafield => 'items.fld1' })->store;
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
# add 952a repeatable in another framework
my $fw = $builder->build({ source => 'BiblioFramework' })->{frameworkcode};
- Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1 })->store;
+ Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1, kohafield => 'items.fld1' })->store;
# Test single value in fld1
my @cols = ( 'items.fld1' => '01' );
$record = C4::Biblio::TransformKohaToMarc( { @cols } );
is( $record->subfield( '952', 'a' ), '01 | 02', 'Check composite in 952a' );
# Test with other framework (repeatable)
+ Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-". $fw );
$record = C4::Biblio::TransformKohaToMarc( { @cols }, { framework => $fw } );
is( ($record->subfield( '952', 'a' ))[0], '01', "Framework $fw first 952a" );
is( ($record->subfield( '952', 'a' ))[1], '02', "Framework $fw second 952a" );
+ is( ref(Koha::Caches->get_instance->get_from_cache( "MarcSubfieldStructure-". $fw )), 'HASH', 'We did hit the cache' );
};
# Cleanup