Bugzilla – Attachment 49502 Details for
Bug 15263
XSLT display fetches sysprefs for every result processed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15263: XSLT display fetches sysprefs for every result processed
Bug-15263-XSLT-display-fetches-sysprefs-for-every-.patch (text/plain), 5.82 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-03-24 02:56:35 UTC
(
hide
)
Description:
Bug 15263: XSLT display fetches sysprefs for every result processed
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-03-24 02:56:35 UTC
Size:
5.82 KB
patch
obsolete
>From cd98d00ad5bcca6f26df524fd4332631cceea1a1 Mon Sep 17 00:00:00 2001 >From: Mirko Tietgen <mirko@abunchofthings.net> >Date: Sun, 29 Nov 2015 20:35:19 +0100 >Subject: [PATCH] Bug 15263: XSLT display fetches sysprefs for every result > processed > >On search, every single result goes through some XSLT processing. >This includes fetching the relevant sysprefs every single time. >We should do it only once per search. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Search.pm | 13 ++++++++++--- > C4/XSLT.pm | 53 +++++++++++++++++++++++++++++------------------------ > 2 files changed, 39 insertions(+), 27 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index fcbb660..58f9383 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1864,6 +1864,13 @@ sub searchResults { > # We get the biblionumber position in MARC > my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber',''); > >+ # set stuff for XSLT processing here once, not later again for every record we retrieved >+ my $interface = $search_context eq 'opac' ? 'OPAC' : ''; >+ my $xslsyspref = $interface . "XSLTResultsDisplay"; >+ my $xslfile = C4::Context->preference($xslsyspref); >+ my $lang = C4::Languages::getlanguage(); >+ my ($sysxml) = C4::XSLT::_get_xslt_sysprefs(); >+ > # loop through all of the records we've retrieved > for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) { > >@@ -2192,9 +2199,9 @@ sub searchResults { > } > > # XSLT processing of some stuff >- my $interface = $search_context eq 'opac' ? 'OPAC' : ''; >- if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) { >- $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems); >+ # we fetched the sysprefs already before the loop through all retrieved record! >+ if (!$scan && $xslfile) { >+ $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile); > # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs > } > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 5622e5f..eed1d09 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -157,13 +157,39 @@ sub _get_best_default_xslt_filename { > return $xslfilename; > } > >+sub _get_xslt_sysprefs { >+ my $sysxml = "<sysprefs>\n"; >+ foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow >+ DisplayOPACiconsXSLT URLLinkText viewISBD >+ OPACBaseURL TraceCompleteSubfields UseICU >+ UseAuthoritiesForTracings TraceSubjectSubdivisions >+ Display856uAsImage OPACDisplay856uAsImage >+ UseControlNumber IntranetBiblioDefaultView BiblioDefaultView >+ singleBranchMode OPACItemLocation DisplayIconsXSLT >+ AlternateHoldingsField AlternateHoldingsSeparator >+ TrackClicks opacthemes IdRef / ) >+ { >+ my $sp = C4::Context->preference( $syspref ); >+ next unless defined($sp); >+ $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n"; >+ } >+ >+ # singleBranchMode was a system preference, but no longer is >+ # we can retain it here for compatibility >+ my $singleBranchMode = Koha::Libraries->search->count == 1; >+ $sysxml .= "<syspref name=\"singleBranchMode\">$singleBranchMode</syspref>\n"; >+ >+ $sysxml .= "</sysprefs>\n"; >+ return $sysxml; >+} >+ > sub XSLTParse4Display { >- my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; >- my $xslfilename = C4::Context->preference($xslsyspref); >+ my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_; >+ #my $xslfilename = C4::Context->preference($xslsyspref); > if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { > my $htdocs; > my $theme; >- my $lang = C4::Languages::getlanguage(); >+ # my $lang = C4::Languages::getlanguage(); > my $xslfile; > if ($xslsyspref eq "XSLTDetailsDisplay") { > $htdocs = C4::Context->config('intrahtdocs'); >@@ -198,28 +224,7 @@ sub XSLTParse4Display { > my $record = transformMARCXML4XSLT($biblionumber, $orig_record); > my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); >- my $sysxml = "<sysprefs>\n"; >- foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow >- DisplayOPACiconsXSLT URLLinkText viewISBD >- OPACBaseURL TraceCompleteSubfields UseICU >- UseAuthoritiesForTracings TraceSubjectSubdivisions >- Display856uAsImage OPACDisplay856uAsImage >- UseControlNumber IntranetBiblioDefaultView BiblioDefaultView >- OPACItemLocation DisplayIconsXSLT >- AlternateHoldingsField AlternateHoldingsSeparator >- TrackClicks opacthemes IdRef / ) >- { >- my $sp = C4::Context->preference( $syspref ); >- next unless defined($sp); >- $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n"; >- } >- >- # singleBranchMode was a system preference, but no longer is >- # we can retain it here for compatibility >- my $singleBranchMode = Koha::Libraries->search->count == 1; >- $sysxml .= "<syspref name=\"singleBranchMode\">$singleBranchMode</syspref>\n"; > >- $sysxml .= "</sysprefs>\n"; > $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; > if ($fixamps) { # We need to correct the HTML entities that Zebra outputs > $xmlrecord =~ s/\&amp;/\&/g; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15263
:
45221
|
48962
|
48963
|
49031
|
49159
|
49502
|
49503
|
49504
|
49505
|
50474
|
50506
|
50507
|
50508
|
50509
|
50510
|
50511