Commit 14580d7f authored by sikeda's avatar sikeda
Browse files

[-bug] Template parse errors were not logged properly.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12306 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 18f2e805
......@@ -283,10 +283,9 @@ sub create_list_old {
Sympa::Template->new($robot,
subdir => 'create_list_templates/' . $list_tpl);
unless ($template->parse($param, 'config.tt2', \$config)) {
my $error = $template->{last_error};
$log->syslog(
'err', 'Can\'t parse %s/config.tt2: %s',
$list_tpl, ($error and $error->info or 'Unknown error')
'err', 'Can\'t parse %s/config.tt2: %s',
$list_tpl, $template->{last_error}
);
return undef;
}
......@@ -467,14 +466,13 @@ sub create_list {
Sympa::Template->new(undef, include_path => [$family->{'dir'}]);
my $tt_result = $template->parse($param, 'config.tt2', \$conf);
if (not $tt_result and $abort_on_error) {
my $error = $template->{last_error};
$log->syslog(
'err',
'Abort on tt2 error. List %s from family %s@%s, file config.tt2 : %s',
'Abort on template error. List %s from family %s@%s, file config.tt2 : %s',
$param->{'listname'},
$family->{'name'},
$robot,
($error and $error->info)
$template->{last_error}
);
return undef;
}
......@@ -552,15 +550,14 @@ sub create_list {
my $tt_result =
$template->parse($param, $file . ".tt2", \$file_content);
unless (defined $tt_result) {
my $error = $template->{last_error};
$log->syslog(
'err',
'Tt2 error. List %s from family %s@%s, file %s : %s',
'Template error. List %s from family %s@%s, file %s : %s',
$param->{'listname'},
$family->{'name'},
$robot,
$file,
($error and $error->info)
$template->{last_error}
);
}
unless (open FILE, '>', "$list_dir/$file") {
......@@ -679,9 +676,8 @@ sub update_list {
my $template =
Sympa::Template->new(undef, include_path => [$family->{'dir'}]);
unless ($template->parse($param, 'config.tt2', $lock_fh)) {
my $error = $template->{last_error};
$log->syslog('err', 'Can\'t parse %s/config.tt2: %s',
$family->{'dir'}, ($error and $error->info));
$family->{'dir'}, $template->{last_error});
return undef;
}
## Unlock config file
......@@ -729,7 +725,6 @@ sub update_list {
my $tt_result =
$template->parse($param, $file . ".tt2", \$file_content);
unless ($tt_result) {
my $error = $template->{last_error};
$log->syslog(
'err',
'Template error. List %s from family %s@%s, file %s: %s',
......@@ -737,7 +732,7 @@ sub update_list {
$family->{'name'},
$robot,
$file,
($error and $error->info)
$template->{last_error}
);
next; #FIXME: Abort processing and rollback.
}
......
......@@ -1633,9 +1633,8 @@ sub distribute_msg {
};
my $template = Sympa::Template->new(undef);
unless ($template->parse($data, [$custom_subject], \$parsed_tag)) {
my $error = $template->{last_error};
$log->syslog('err', 'Can\'t parse custom_subject of list %s: %s',
$self, ($error and $error->info));
$self, $template->{last_error});
undef $parsed_tag;
}
......@@ -8653,8 +8652,8 @@ sub sync_include_admin {
if ($#add_tab >= 0) {
unless ($admin_users_added =
$self->add_list_admin($role, @add_tab)) {
$log->syslog('err', '(%s) Failed to add new %ss',
$role, $name);
$log->syslog('err', 'Failed to add new %s(s) to list %s',
$role, $self);
return undef;
}
}
......
......@@ -109,6 +109,8 @@ sub syslog {
unless (defined $p) {
# prevent 'Use of uninitialized value' warning
push @param, '';
} elsif (ref $p eq 'Template::Exception') {
push @param, $p->as_string;
} elsif (Scalar::Util::blessed($p) and $p->can('get_id')) {
push @param, sprintf('%s <%s>', ref $p, $p->get_id);
} elsif (ref $p eq 'Regexp') {
......
......@@ -514,10 +514,9 @@ sub _new_from_template {
($list ? [$list->{'dir'}, $list->{'dir'} . '/archives'] : [])
);
unless ($template->parse($data, $filename, \$message_as_string)) {
my $error = $template->{last_error};
$log->syslog(
'err', 'Can\'t parse template %s: %s',
$filename, ($error and $error->info)
'err', 'Can\'t parse template %s: %s',
$filename, $template->{last_error}
);
return undef;
}
......@@ -2391,11 +2390,10 @@ sub _urlize_one_part {
lang => $language->get_lang
);
unless ($template->parse($data, 'urlized_part.tt2', \$new_part)) {
my $error = $template->{last_error};
$log->syslog(
'err',
'Can\'t parse template urlized_part.tt2: %s',
($error and $error->info)
$template->{last_error}
);
return undef;
}
......
......@@ -1206,8 +1206,7 @@ sub fullReview {
# Members list synchronization if include is in use
if ($list->has_include_data_sources()) {
unless (defined $list->on_the_fly_sync_include(use_ttl => 1)) {
$log->syslog('notice', 'Unable to synchronize list %s',
$list);
$log->syslog('notice', 'Unable to synchronize list %s', $list);
}
}
......@@ -1923,6 +1922,7 @@ sub get_reason_string {
Sympa::Template->new($robot, subdir => 'mail_tt2'); # FIXME: lang?
unless ($template->parse($data, 'authorization_reject.tt2', \$string)) {
my $error = $template->{last_error};
$error = $error->as_string if ref $error;
Sympa::send_notify_to_listmaster($robot, 'web_tt2_error', [$error]);
$log->syslog('info', 'Error parsing');
return '';
......
......@@ -804,6 +804,7 @@ sub update_css {
Sympa::Template->new($robot, subdir => 'web_tt2');
unless ($css_template->parse($param, 'css.tt2', \*CSS)) {
my $error = $css_template->{last_error};
$error = $error->as_string if ref $error;
$param->{'tt2_error'} = $error;
Sympa::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment