@@ -, +, @@ --- C4/XSLT.pm | 6 ++++++ t/db_dependent/XSLT.t | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -73,6 +73,12 @@ sub transformMARCXML4XSLT { }; if ($@) { warn "PROBLEM WITH RECORD"; next; } my $marcflavour = C4::Context->preference('marcflavour'); + + # FIXME: This should properly use the cache in the future, but is here to save on performance where possible + $av = getAuthorisedValues4MARCSubfields("") unless $av; + $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' })->as_list } unless $branches; + $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } } unless $itemtypes; + foreach my $tag ( keys %$av ) { foreach my $field ( $record->field( $tag ) ) { if ( defined $av->{ $tag } ) { --- a/t/db_dependent/XSLT.t +++ a/t/db_dependent/XSLT.t @@ -79,10 +79,10 @@ subtest 'transformMARCXML4XSLT tests' => sub { $av->{952}->{a}->{$auth_val->category}->{$auth_val->authorised_value}->{lib} = ""; $record->field(952)->update( a => $auth_val->authorised_value, c => $branch_2->branchcode, d => $itemtype_2->itemtype ); - C4::XSLT::transformMARCXML4XSLT( 3, $record, $branches, $itemtypes, $av ); + C4::XSLT::transformMARCXML4XSLT( 3, $record, 0, $branches, $itemtypes, $av ); is($record->subfield( '952', 'a' ),$auth_val->authorised_value,'952$a is not transformed when value found but blank'); - is($record->subfield( '952', 'c' ),$branch_2->branchcode,'952$c is returned unaltered invalid branchcode'); - is($record->subfield( '952', 'd' ),$itemtype_2->itemtype,'952$d is returned unaltered when invalid itemtype'); + is($record->subfield( '952', 'c' ),"",'952$c is returned blank when invalid branchcode'); + is($record->subfield( '952', 'd' ),"",'952$d is returned blank when invalid itemtype'); }; --