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 Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
919736afcc
commit
70325d48a0
|
|
@ -2017,13 +2017,18 @@ sub searchResults {
|
|||
),
|
||||
fix_amps => 1,
|
||||
hidden_items => \@hiddenitems,
|
||||
xslt_variables => $xslt_variables
|
||||
xslt_variables => $xslt_variables,
|
||||
interface => $search_context->{'interface'}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
my $biblio_object = Koha::Biblios->find( $oldbiblio->{biblionumber} );
|
||||
$oldbiblio->{biblio_object} = $biblio_object;
|
||||
$oldbiblio->{coins} = eval { $biblio_object->get_coins }
|
||||
if $biblio_object
|
||||
&& C4::Context->preference('COinSinOPACResults')
|
||||
&& $is_opac;
|
||||
|
||||
my $can_place_holds = 1;
|
||||
# if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ sub XSLTParse4Display {
|
|||
my $hidden_items = $params->{hidden_items} || [];
|
||||
my $variables = $params->{xslt_variables};
|
||||
my $items_rs = $params->{items_rs};
|
||||
my $interface = $params->{interface};
|
||||
|
||||
die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}"
|
||||
if not defined $params->{xsl_syspref};
|
||||
|
|
@ -208,7 +209,7 @@ sub XSLTParse4Display {
|
|||
|
||||
$variables ||= {};
|
||||
my $biblio;
|
||||
if (C4::Context->preference('OPACShowOpenURL')) {
|
||||
if ( $interface eq 'opac' && C4::Context->preference('OPACShowOpenURL')) {
|
||||
my @biblio_itemtypes;
|
||||
$biblio //= Koha::Biblios->find($biblionumber);
|
||||
if (C4::Context->preference('item-level_itypes')) {
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
|
|||
record => $part,
|
||||
xsl_syspref => "XSLTResultsDisplay",
|
||||
fix_amps => 1,
|
||||
interface => 'intranet'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -284,6 +285,7 @@ $template->param(
|
|||
xsl_syspref => "XSLTDetailsDisplay",
|
||||
fix_amps => 1,
|
||||
xslt_variables => $xslt_variables,
|
||||
interface => 'intranet'
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -612,6 +612,7 @@ if ( $showcomp eq 'both' || $showcomp eq 'opac' ) {
|
|||
record => $part,
|
||||
xsl_syspref => 'OPACXSLTResultsDisplay',
|
||||
fix_amps => 1,
|
||||
interface => 'opac'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -647,6 +648,7 @@ $template->param(
|
|||
xsl_syspref => 'OPACXSLTDetailsDisplay',
|
||||
fix_amps => 1,
|
||||
xslt_variables => $variables,
|
||||
interface => 'opac'
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -659,11 +659,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;
|
||||
|
|
|
|||
|
|
@ -416,6 +416,7 @@ if ( $op eq 'view' ) {
|
|||
fix_amps => 1,
|
||||
xslt_variables => $variables,
|
||||
items_rs => $items->reset,
|
||||
interface => 'opac'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ if ($loggedinuser) {
|
|||
fix_amps => 1,
|
||||
hidden_items => \@hidden_items,
|
||||
xslt_variables => $variables
|
||||
interface => 'opac'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ if ( $op eq 'view' ) {
|
|||
record => $record,
|
||||
xsl_syspref => 'XSLTListsDisplay',
|
||||
fix_amps => 1,
|
||||
interface => 'intranet'
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue