From 456dd4c9f1030c0dcccb56c465d5693900c4d57b Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Tue, 22 Jun 2021 11:52:18 +0300 Subject: [PATCH] Bug 23035: Use GetAuthorisedValues in transformMARCXML4XSLT Intranet search is slow if thousands of items are in the biblios shown in the search results. Using GetAuthorisedValues (which uses cache) instead of GetAuthorisedValueDesc in transformMARCXML4XSLT significantly speeds up search time. To test: 1. Add biblio or biblios with hundreds/thousands items. 2. Tab F12 and select 'Network' to view time spent on search. 3. Perform search, note how long search takes to finnish. 4. Apply patch. 5. Repeat search. => Note that search should now work faster. Also prove t/db_dependent/XSLT.t Sponsored-by: Koha-Suomi Oy --- C4/XSLT.pm | 2 +- t/db_dependent/XSLT.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 3cdf451b28..e9dbec5a40 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -85,7 +85,7 @@ sub transformMARCXML4XSLT { my ( $letter, $value ) = @$subfield; # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac) if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) { - $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib ) + $value = GetAuthorisedValues( $tag, $letter, $value, '', $tagslib ) if $av->{ $tag }->{ $letter }; } push( @new_subfields, $letter, $value ); diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 37637e6fa8..b8e68dccc6 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -38,7 +38,7 @@ subtest 'transformMARCXML4XSLT tests' => sub { plan tests => 1; my $mock_xslt = Test::MockModule->new("C4::XSLT"); $mock_xslt->mock( getAuthorisedValues4MARCSubfields => sub { return { 942 => { 'n' => 1 } } } ); - $mock_xslt->mock( GetAuthorisedValueDesc => sub { warn "called"; }); + $mock_xslt->mock( GetAuthorisedValues=> sub { warn "called"; }); my $record = MARC::Record->new(); my $suppress_field = MARC::Field->new( 942, ' ', ' ', n => '1' ); $record->append_fields($suppress_field); -- 2.25.1