View | Details | Raw Unified | Return to bug 24715
Collapse All | Expand All

(-)a/C4/Biblio.pm (-5 / +12 lines)
Lines 1990-1996 sub TransformKohaToMarc { Link Here
1990
1990
1991
    # In the next call we use the Default framework, since it is considered
1991
    # In the next call we use the Default framework, since it is considered
1992
    # authoritative for Koha to Marc mappings.
1992
    # authoritative for Koha to Marc mappings.
1993
    my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framewok
1993
    my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework
1994
    my $mss2; # belongs to $params->{framework} only filled when needed
1994
    my $tag_hr = {};
1995
    my $tag_hr = {};
1995
    while ( my ($kohafield, $value) = each %$hash ) {
1996
    while ( my ($kohafield, $value) = each %$hash ) {
1996
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
1997
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
Lines 1999-2005 sub TransformKohaToMarc { Link Here
1999
            next if !$tagfield;
2000
            next if !$tagfield;
2000
2001
2001
            # BZ 21800: split value if field is repeatable.
2002
            # BZ 21800: split value if field is repeatable.
2002
            my @values = _check_split($params, $fld, $value)
2003
            my @values = _check_split($params, $mss2, $fld, $value)
2003
                ? split(/\s?\|\s?/, $value, -1)
2004
                ? split(/\s?\|\s?/, $value, -1)
2004
                : ( $value );
2005
                : ( $value );
2005
            foreach my $value ( @values ) {
2006
            foreach my $value ( @values ) {
Lines 2023-2029 sub TransformKohaToMarc { Link Here
2023
}
2024
}
2024
2025
2025
sub _check_split {
2026
sub _check_split {
2026
    my ($params, $fld, $value) = @_;
2027
    my ($params, $mss2, $fld, $value) = @_;
2027
    return if index($value,'|') == -1; # nothing to worry about
2028
    return if index($value,'|') == -1; # nothing to worry about
2028
    return if $params->{no_split};
2029
    return if $params->{no_split};
2029
2030
Lines 2031-2038 sub _check_split { Link Here
2031
    return $fld->{repeatable} if !$params->{framework};
2032
    return $fld->{repeatable} if !$params->{framework};
2032
2033
2033
    # here we need to check the specific framework
2034
    # here we need to check the specific framework
2034
    my $mss = Koha::MarcSubfieldStructures->find( $params->{framework}, $fld->{tagfield}, $fld->{tagsubfield} );
2035
    $mss2 = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 })
2035
    return 1 if $mss && $mss->repeatable;
2036
        if !$mss2;
2037
    foreach my $fld2 ( @{ $mss2->{ $fld->{kohafield} } } ) {
2038
        next if $fld2->{tagfield} ne $fld->{tagfield};
2039
        next if $fld2->{tagsubfield} ne $fld->{tagsubfield};
2040
        return 1 if $fld2->{repeatable};
2041
    }
2042
    return;
2036
}
2043
}
2037
2044
2038
=head2 PrepHostMarcField
2045
=head2 PrepHostMarcField
(-)a/t/db_dependent/Biblio/TransformKohaToMarc.t (-2 / +1 lines)
Lines 88-94 subtest "Add tests for _check_split" => sub { Link Here
88
    Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
88
    Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
89
    # add 952a repeatable in another framework
89
    # add 952a repeatable in another framework
90
    my $fw =  $builder->build({ source => 'BiblioFramework' })->{frameworkcode};
90
    my $fw =  $builder->build({ source => 'BiblioFramework' })->{frameworkcode};
91
    Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1 })->store;
91
    Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1, kohafield => 'items.fld1' })->store;
92
92
93
    # Test single value in fld1
93
    # Test single value in fld1
94
    my @cols = ( 'items.fld1' => '01' );
94
    my @cols = ( 'items.fld1' => '01' );
95
- 

Return to bug 24715