Disable template cache to avoid translation issues in mail (#1897)

This commit is contained in:
Maxime Besson 2019-08-27 11:01:32 +02:00
parent a04a376777
commit 810d2c7f94
3 changed files with 20 additions and 8 deletions

View File

@ -84,6 +84,8 @@ has transport => (
sub loadMailTemplate {
my ( $self, $req, $name, %prm ) = @_;
# HTML::Template cache interferes with email translation (#1897)
$prm{cache} = 0 unless defined $prm{cache};
$prm{params}->{STATIC_PREFIX} = $self->p->staticPrefix;
my %extra =
$self->p->can('tplParams')

View File

@ -1058,7 +1058,7 @@ sub loadTemplate {
search_path_on_include => 1,
die_on_bad_params => 0,
die_on_missing_include => 1,
cache => 1,
cache => ( defined $prm{cache} ? $prm{cache} : 1 ),
global_vars => 0,
( $prm{filter} ? ( filter => $prm{filter} ) : () ),
);

View File

@ -10,10 +10,7 @@ BEGIN {
}
my ( $res, $user, $pwd );
my $maintests = 9;
my $mailSend = 0;
my $mail2 = 0;
my $maintests = 12;
SKIP: {
eval
@ -50,7 +47,20 @@ SKIP: {
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
accept => 'text/html',
cookie => 'llnglanguage=fr',
),
'Post mail'
);
like( mail(), qr#<span>Bonjour</span>#, "Found french greeting" );
# Test another language (#1897)
ok(
$res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html',
cookie => 'llnglanguage=en',
),
'Post mail'
);
@ -62,6 +72,8 @@ SKIP: {
ok( mail() =~ m%Content-Type: image/png; name="logo_llng_old.png"%,
'Found custom Main logo in mail' )
or print STDERR Dumper( mail() );
like( mail(), qr#<span>Hello</span>#, "Found english greeting" );
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#,
'Found link in mail' );
$query = $1;
@ -89,8 +101,6 @@ SKIP: {
);
ok( mail() =~ /Your password was changed/, 'Password was changed' );
#print STDERR Dumper($query);
}
count($maintests);