Bugzilla – Attachment 139677 Details for
Bug 31373
Notice template validation is missing INCLUDE_PATH
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31373: DRY - Use try/catch around _process_tt
Bug-31373-DRY---Use-trycatch-around-processtt.patch (text/plain), 3.37 KB, created by
Kyle M Hall (khall)
on 2022-08-23 13:25:14 UTC
(
hide
)
Description:
Bug 31373: DRY - Use try/catch around _process_tt
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-08-23 13:25:14 UTC
Size:
3.37 KB
patch
obsolete
>From 69ae1b410a514739670a8da3e1c71946fa2d5b0a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 18 Aug 2022 17:21:31 +0100 >Subject: [PATCH] Bug 31373: DRY - Use try/catch around _process_tt > >This patch reduces the repetition in the tools/letter.pl controller >replaceing it with a try/catch block wrapping a call to >C4::Letters::_process_tt instead. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Letters.pm | 2 +- > tools/letter.pl | 38 ++++++++++---------------------------- > 2 files changed, 11 insertions(+), 29 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 7c136f32f9..bde0d2b0dc 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1578,7 +1578,7 @@ sub _process_tt { > my $content = $params->{content}; > my $tables = $params->{tables}; > my $loops = $params->{loops}; >- my $objects = $params->{objects}; >+ my $objects = $params->{objects} || {}; > my $substitute = $params->{substitute} || {}; > my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en'; > my ($theme, $availablethemes); >diff --git a/tools/letter.pl b/tools/letter.pl >index 420556ff75..d709b2d6e9 100755 >--- a/tools/letter.pl >+++ b/tools/letter.pl >@@ -42,7 +42,7 @@ > > use Modern::Perl; > use CGI qw ( -utf8 ); >-use Template; >+use Try::Tiny; > > use C4::Auth qw( get_template_and_user ); > use C4::Context; >@@ -197,29 +197,8 @@ 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( >- { >- EVAL_PERL => 1, >- ABSOLUTE => 1, >- PLUGIN_BASE => 'Koha::Template::Plugin', >- INCLUDE_PATH => \@includes, >- FILTERS => {}, >- ENCODING => 'UTF-8', >- } >- ); >- > for my $letter ( @$letters ) { > # The letter_name > if ( $first_flag_name and $letter->{name} ) { >@@ -229,12 +208,15 @@ sub add_form { > $first_flag_name = 0; > } > >- 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(); >- } >+ # Catch template issues >+ try { >+ C4::Letters::_process_tt($letter); >+ } catch { >+ my $error = $_; >+ $error =~ s/^ERROR PROCESSING TEMPLATE: //; >+ $error =~ s/at .*\/tools\/letter\.pl line 213\.$//; >+ $letter->{tt_error} = $error; >+ }; > > my $lang = $letter->{lang}; > my $mtt = $letter->{message_transport_type}; >-- >2.30.2
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 31373
:
139210
|
139211
|
139406
|
139677
|
140456
|
140457