From 69ee0044a293409966c6be7cfbe1e727892ed627 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 18 May 2021 15:59:53 +0000 Subject: [PATCH] Bug 28375: Inefficiencies in fetching COinS This patchset adds an 'interface' parameter to XSLTParseForDisplay to avoid fetching coins when not needed Additionally we move some logic from the scripts to searchResults to avoid an extra fetch fo the biblio object To test: 1 - Enable COinSinOPACResults syspref 2 - Also enable OPACShowOpenURL and OPACOpenURLItemTypes - adding an itemtype that you can find 3 - Perform a search on the OPAC and confirm coins are included and openurl shown 4 - Perform a search on staff client and confirm openurls do not show 5 - Apply patch 6 - Results should be the same --- C4/Search.pm | 2 +- C4/XSLT.pm | 4 ++-- catalogue/detail.pl | 2 +- opac/opac-detail.pl | 2 +- opac/opac-search.pl | 5 ----- opac/opac-shelves.pl | 2 +- opac/opac-tags.pl | 2 +- virtualshelves/shelves.pl | 2 +- 8 files changed, 8 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 5bc6580e2c..2e5514d6e7 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2020,7 +2020,7 @@ sub searchResults { }); $record_processor->process($marcrecord); - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables); + $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables, $search_context->{'interface'} ); } # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 3cdf451b28..5393303746 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -190,7 +190,7 @@ sub get_xslt_sysprefs { } sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables ) = @_; + my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables , $interface ) = @_; $sysxml ||= C4::Context->preference($xslsyspref); $xslfilename ||= C4::Context->preference($xslsyspref); @@ -251,7 +251,7 @@ sub XSLTParse4Display { my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); $variables ||= {}; - if (C4::Context->preference('OPACShowOpenURL')) { + if ( $interface eq 'opac' && C4::Context->preference('OPACShowOpenURL')) { my @biblio_itemtypes; my $biblio = Koha::Biblios->find($biblionumber); if (C4::Context->preference('item-level_itypes')) { diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 8d06f0da51..b1ab6e08c1 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -147,7 +147,7 @@ if ( $xslfile ) { XSLTBloc => XSLTParse4Display( $biblionumber, $record, "XSLTDetailsDisplay", 1, undef, $sysxml, $xslfile, $lang, - $variables + $variables, 'intranet' ) ); } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 6173b72862..aacaf4c896 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -215,7 +215,7 @@ if ( $xslfile ) { $template->param( XSLTBloc => XSLTParse4Display( $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef, - $sysxml, $xslfile, $lang, $variables + $sysxml, $xslfile, $lang, $variables, 'opac' ) ); } diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 878d97826f..6e6281b143 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -702,11 +702,6 @@ for (my $i=0;$i<@servers;$i++) { $res->{'incart'} = 1; } - if (C4::Context->preference('COinSinOPACResults')) { - my $biblio = Koha::Biblios->find( $res->{'biblionumber'} ); - # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid - $res->{coins} = $biblio ? eval {$biblio->get_coins} : q{}; # FIXME This should be moved at the beginning of the @newresults loop - } if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) { if( my $isbn = Business::ISBN->new( $res->{normalized_isbn} ) ) { $isbn = $isbn->as_isbn13->as_string; diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index b94b4126ea..9cfc515ad5 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -326,7 +326,7 @@ if ( $op eq 'view' ) { "OPACXSLTListsDisplay", 1, undef, $sysxml, $xslfile, $lang, - $variables + $variables, 'opac' ); } diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 05a4c1a74a..e96cb9dcb6 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -300,7 +300,7 @@ if ($loggedinuser) { "OPACXSLTResultsDisplay", 1, $hidden_items, $sysxml, $xslfile, $lang, - $variables + $variables, 'opac' ); } diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index d233eb1355..cc78d516bf 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -265,7 +265,7 @@ if ( $op eq 'view' ) { if ( $xslfile ) { $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTListsDisplay", - 1, undef, $sysxml, $xslfile, $lang); + 1, undef, $sysxml, $xslfile, $lang, undef, 'intranet'); } my $marcflavour = C4::Context->preference("marcflavour"); -- 2.11.0