From 1efbefef1b5152f45b0ea21ed6de4a7ddc5d1a41 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 16 Aug 2022 17:08:40 +0100 Subject: [PATCH] Bug 31373: Add INCLUDE_PATH to notice validation Content-Type: text/plain; charset=utf-8 This is a follow-up to bug 31211. It adds the same INCLUDE_PATH variables as C4::Templates adds during processing to prevent false failures. Test plan 1) Add an INCLUDE to any valid notice, for example: [% INCLUDE 'patron-title.inc' patron => patron %] 2) Save and continue 3) Confirm you are faced with a validation error complaining that the include file cannot be found 4) Apply this patch 5) Confirm that the reported error has dissapeared Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy --- tools/letter.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/letter.pl b/tools/letter.pl index 35d9a12d14..420556ff75 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -196,6 +196,17 @@ sub add_form { ); my $first_flag_name = 1; my $lang; + + # Get available includes + my $htdocs = C4::Context->config('intrahtdocs'); + my ($theme, $availablethemes); + ($theme, $lang, $availablethemes)= C4::Templates::availablethemes( $htdocs, 'about.tt', 'intranet', $lang); + my @includes; + foreach (@$availablethemes) { + push @includes, "$htdocs/$_/$lang/includes"; + push @includes, "$htdocs/$_/en/includes" unless $lang eq 'en'; + } + # The letter name is contained into each mtt row. # So we can only sent the first one to the template. my $tt = Template->new( @@ -203,6 +214,7 @@ sub add_form { EVAL_PERL => 1, ABSOLUTE => 1, PLUGIN_BASE => 'Koha::Template::Plugin', + INCLUDE_PATH => \@includes, FILTERS => {}, ENCODING => 'UTF-8', } @@ -219,6 +231,7 @@ sub add_form { my $output; my $template = $letter->{content}; + $template = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %][% PROCESS 'html_helpers.inc' %]$template|; unless ( $tt->process( \$template, {}, \$output ) ) { $letter->{tt_error} = $tt->error(); } -- 2.20.1