From: Bill Erickson Date: Mon, 22 Apr 2019 15:17:50 +0000 (-0700) Subject: LP1825851 Default to no template caching X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=543e3b8cac01d05865eadbe94f20dcd5746a805e;p=working%2FEvergreen.git LP1825851 Default to no template caching To enable template cacheing, passing a true value as the second import argument for PrintTemplate in eg_startup.pl Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/examples/apache_24/eg_startup.in b/Open-ILS/examples/apache_24/eg_startup.in index 316034a424..72e2903d09 100755 --- a/Open-ILS/examples/apache_24/eg_startup.in +++ b/Open-ILS/examples/apache_24/eg_startup.in @@ -15,7 +15,7 @@ use OpenILS::WWW::IDL2js ('@sysconfdir@/opensrf_core.xml'); use OpenILS::WWW::FlatFielder; use OpenILS::WWW::PhoneList ('@sysconfdir@/opensrf_core.xml'); -# Pass second argument of '1' to disable template caching. +# Pass second argument of '1' to enable template caching. use OpenILS::WWW::PrintTemplate ('/openils/conf/opensrf_core.xml', 0); # - Uncomment the following 2 lines to make use of the IP redirection code diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm index bd9f52b587..2c33f787c8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm @@ -4,7 +4,11 @@ use Apache2::Const -compile => qw(OK FORBIDDEN NOT_FOUND HTTP_INTERNAL_SERVER_ERROR HTTP_BAD_REQUEST); use Apache2::RequestRec; use CGI; -use HTML::Restrict; +# Requires a new CPAN module. +# Leaving commented for now to ease testing, pending agreement on the +# approach for html srubbing. +# $ sudo cpan HTML::Restrict +#use HTML::Restrict; use OpenSRF::Utils::JSON; use OpenSRF::System; use OpenSRF::Utils::SettingsClient; @@ -14,10 +18,10 @@ use OpenILS::Application::AppUtils; my $U = 'OpenILS::Application::AppUtils'; my $bs_config; -my $disable_cache; +my $enable_cache; # Enable process-level template caching sub import { $bs_config = shift; - $disable_cache = shift; + $enable_cache = shift; } my $init_complete = 0; @@ -25,7 +29,7 @@ sub child_init { $init_complete = 1; OpenSRF::System->bootstrap_client(config_file => $bs_config); - OpenILS::Utils::CStoreEditor->init; # just in case + OpenILS::Utils::CStoreEditor->init; return Apache2::Const::OK; } @@ -56,7 +60,9 @@ my $rules = { u => [qw(class style)], ul => [qw(class style)], }; -my $hr = HTML::Restrict->new(rules => $rules); + +my $hr; +#my $hr = HTML::Restrict->new(rules => $rules); sub handler { my $r = shift; @@ -103,9 +109,8 @@ sub handler { if ($stat) { # OK my $ctype = $template->content_type; - if ($ctype eq 'text/html') { - # Scrub the HTML - $output = $hr->process($output); + if ($hr && $ctype eq 'text/html') { + $output = $hr->process($output); # Scrub the HTML } # TODO # client current expects content type to only contain type. @@ -134,12 +139,13 @@ sub find_template { } return $template_cache{$owner}{$name}{$locale} - if $template_cache{$owner} && + if $enable_cache && + $template_cache{$owner} && $template_cache{$owner}{$name} && $template_cache{$owner}{$name}{$locale}; while ($owner) { - my ($org) = $U->fetch_org_unit($owner); # internally cached + my ($org) = $U->fetch_org_unit($owner); # cached in AppUtils my $template = $e->search_config_print_template({ name => $name, @@ -149,7 +155,8 @@ sub find_template { })->[0]; if ($template) { - if (!$disable_cache) { + + if ($enable_cache) { $template_cache{$owner} = {} unless $template_cache{$owner}; $template_cache{$owner}{$name} = {} unless $template_cache{$owner}{$name};