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

(-)a/C4/XSLT.pm (+6 lines)
Lines 73-78 sub transformMARCXML4XSLT { Link Here
73
    };
73
    };
74
    if ($@) { warn "PROBLEM WITH RECORD"; next; }
74
    if ($@) { warn "PROBLEM WITH RECORD"; next; }
75
    my $marcflavour = C4::Context->preference('marcflavour');
75
    my $marcflavour = C4::Context->preference('marcflavour');
76
77
    # FIXME: This should properly use the cache in the future, but is here to save on performance where possible
78
    $av = getAuthorisedValues4MARCSubfields("") unless $av;
79
    $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' })->as_list } unless $branches;
80
    $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } } unless $itemtypes;
81
76
    foreach my $tag ( keys %$av ) {
82
    foreach my $tag ( keys %$av ) {
77
        foreach my $field ( $record->field( $tag ) ) {
83
        foreach my $field ( $record->field( $tag ) ) {
78
            if ( defined $av->{ $tag } ) {
84
            if ( defined $av->{ $tag } ) {
(-)a/t/db_dependent/XSLT.t (-4 / +3 lines)
Lines 79-88 subtest 'transformMARCXML4XSLT tests' => sub { Link Here
79
79
80
    $av->{952}->{a}->{$auth_val->category}->{$auth_val->authorised_value}->{lib} = "";
80
    $av->{952}->{a}->{$auth_val->category}->{$auth_val->authorised_value}->{lib} = "";
81
    $record->field(952)->update( a => $auth_val->authorised_value, c => $branch_2->branchcode, d => $itemtype_2->itemtype );
81
    $record->field(952)->update( a => $auth_val->authorised_value, c => $branch_2->branchcode, d => $itemtype_2->itemtype );
82
    C4::XSLT::transformMARCXML4XSLT( 3, $record, $branches, $itemtypes, $av );
82
    C4::XSLT::transformMARCXML4XSLT( 3, $record, 0, $branches, $itemtypes, $av );
83
    is($record->subfield( '952', 'a' ),$auth_val->authorised_value,'952$a is not transformed when value found but blank');
83
    is($record->subfield( '952', 'a' ),$auth_val->authorised_value,'952$a is not transformed when value found but blank');
84
    is($record->subfield( '952', 'c' ),$branch_2->branchcode,'952$c is returned unaltered invalid branchcode');
84
    is($record->subfield( '952', 'c' ),"",'952$c is returned blank when invalid branchcode');
85
    is($record->subfield( '952', 'd' ),$itemtype_2->itemtype,'952$d is returned unaltered when invalid itemtype');
85
    is($record->subfield( '952', 'd' ),"",'952$d is returned blank when invalid itemtype');
86
86
87
87
88
};
88
};
89
- 

Return to bug 28371