From 34a0e7cc8b595c4ea45f9e5480ab3200044b6448 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 4 Nov 2016 11:41:16 -0400 Subject: [PATCH] Bug 17527: Avoid double filtering and floody log clean up Because the filtering filters parameter values, C4/Output was triggering floody output. During testing, everything was set to hidden=-8. While this is not realistic, it did uncover some floodiness which may have already existed with the non-XSLT output. OPAC did have a double filtering call, because of the poor design of the template. An if condition around the processor call prevents that, while still allowing the template to work. TEST PLAN --------- 0) Back up your DB 1) in marc_subfield_structure, set all hidden=-8 -- this makes everything hidden everywhere. -- it is completely arbitrary, any value which hides in OPAC would suffice for this patch. 2) in the staff client, make sure the OPACXSLTDetailsDisplay system preference is 'default' or some custome template -- default was used for testing. 3) make sure at least one book is entered in the system -- my testing assumes 1 -- testing data set only had book with 'carbs' in title. 4) search for 'carbs' in the OPAC -- because I only had 1 match it redirected to results. -- material type 'book' comes from LDR, which is not filtered. -- the items section is built and not part of the filter. -- should be painfully sparse 5) select the three views -- all should be painfully sparse 6) select 'view plain' in the MARC view tab. -- painfully sparse 7) run koha qa test tools NOTE: This patch only needs testing in OPAC. --- C4/Output.pm | 2 +- opac/opac-ISBDdetail.pl | 6 ++++-- opac/opac-MARCdetail.pl | 6 ++++-- opac/opac-detail.pl | 14 +++++++++----- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index af7dd5a..c59e760 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -311,7 +311,7 @@ sub parametrized_url { my $vars = shift || {}; # ie { LANG => en } my $ret = $url; while ( my ($key,$val) = each %$vars) { - my $val_url = URI::Escape::uri_escape_utf8($val); + my $val_url = defined($val) ? URI::Escape::uri_escape_utf8($val) : q{}; $ret =~ s/\{$key\}/$val_url/g; } $ret =~ s/\{[^\{]*\}//g; # remove not defined vars diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 357f2f8..d508c50 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -191,8 +191,10 @@ my $marcissns = GetMarcISSN ( $record, $marcflavour ); my $issn = $marcissns->[0] || ''; if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ - $dat->{title} =~ s/\/+$//; # remove trailing slash - $dat->{title} =~ s/\s+$//; # remove trailing space + if (defined($dat->{title})) { + $dat->{title} =~ s/\/+$//; # remove trailing slash + $dat->{title} =~ s/\s+$//; # remove trailing space + } $search_for_title = parametrized_url( $search_for_title, { diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 3c9c2c2..9996fc6 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -325,8 +325,10 @@ my $marcissns = GetMarcISSN( $record, $marcflavour ); my $issn = $marcissns->[0] || ''; if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ - $dat->{title} =~ s/\/+$//; # remove trailing slash - $dat->{title} =~ s/\s+$//; # remove trailing space + if (defined($dat->{title})) { + $dat->{title} =~ s/\/+$//; # remove trailing slash + $dat->{title} =~ s/\s+$//; # remove trailing space + } $search_for_title = parametrized_url( $search_for_title, { diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 9087118..d3e8d4e 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -89,15 +89,21 @@ if ( ! $record ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early exit; } -my $framework = &GetFrameworkCode( $biblionumber ); + +my $dat = &GetBiblioData($biblionumber); my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy', options => { interface => 'opac', - frameworkcode => $framework + frameworkcode => $dat->{'frameworkcode'} } }); -$record_processor->process($record); + +# Only run filtering on record if not XSLT. +my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay'); +if (! $xslfile ) { + $record_processor->process($record); +} # redirect if opacsuppression is enabled and biblio is suppressed if (C4::Context->preference('OpacSuppression')) { @@ -149,7 +155,6 @@ my $marcflavour = C4::Context->preference("marcflavour"); my $ean = GetNormalizedEAN( $record, $marcflavour ); # XSLT processing of some stuff -my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay'); my $lang = $xslfile ? C4::Languages::getlanguage() : undef; my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; @@ -530,7 +535,6 @@ if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { } } -my $dat = &GetBiblioData($biblionumber); my $HideMARC = $record_processor->filters->[0]->should_hide_marc( { frameworkcode => $dat->{'frameworkcode'}, -- 2.1.4