While upgrading to RT 4.2.1 (from RT 4.0.17) I had to change a few of
our HTML templates.
Previously, we had two quite complex html templates for the Take and the
Resolve actions. I am attaching them here so you can examine them.
Basically they where full html pages with tables and embedded perl code.
After upgrade to RT 4.2.1 we started seeing errors in the log, like this:
[6885] [Mon Dec 23 20:37:52 2013] [error]: Scrip Prepare 10 died. -
Can't call method "content" on an undefined value at
/usr/local/share/perl5/HTML/FormatText/W
ithLinks/AndTables.pm line 217.
Stack:
[/usr/local/share/perl5/HTML/FormatText/WithLinks/AndTables.pm:217]
[/usr/local/share/perl5/HTML/FormatText/WithLinks/AndTables.pm:101]
[/usr/local/share/perl5/HTML/FormatText/WithLinks/AndTables.pm:83]
[/opt/rt4/sbin/../lib/RT/Interface/Email.pm:1777]
[/opt/rt4/sbin/../lib/RT/Template.pm:666]
[/opt/rt4/sbin/../lib/RT/Template.pm:421]
[/opt/rt4/sbin/../lib/RT/Action/SendEmail.pm:139]
[/opt/rt4/sbin/../lib/RT/Action/Notify.pm:69]
[/opt/rt4/sbin/../lib/RT/ScripAction.pm:222]
[/opt/rt4/sbin/../lib/RT/Scrip.pm:561]
[/opt/rt4/sbin/../lib/RT/Scrips.pm:358]
[/opt/rt4/sbin/../lib/RT/Scrips.pm:291]
[/opt/rt4/sbin/../lib/RT/Ticket.pm:2555]
[/opt/rt4/sbin/../lib/RT/Ticket.pm:2526]
[/opt/rt4/sbin/../lib/RT/Ticket.pm:2596]
[/usr/local/share/perl5/HTML/Mason/Request.pm:1295]
[/opt/rt4/share/html/Ticket/autohandler:66]
[/opt/rt4/sbin/../lib/RT/Interface/Web.pm:680]
[/opt/rt4/sbin/../lib/RT/Interface/Web.pm:368]
[/opt/rt4/share/html/autohandler:53]
(/opt/rt4/sbin/../lib/RT/Scrip.pm:564)
I got a hard time figuring out what the problem was, but after a lot of
debugging I found that it was the html code that was giving us problems.
A simple text version of our template was working well. So I tried to
re-add html code step by step. At last I found I could use simple html
tags like <h1>, <h2>, <br />, <hr />, <i>, etc. but I could not add e.g.
tables.
We are now using much simpler html templates (which is not bad in
itself), but I'd like to know if this incompatibility is something that
was planned or not, and if we can somehow restore the layout of our
previous templates and how.
Thank you in advance.
Cristiano
Content-Type: text/html
Subject: Risposta automatica: {$Ticket->Subject}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Risposta automatica: {$Ticket->Subject}</title>
</head>
<body bgcolor="#ffffff">
<table align="center" border="1" cellspacing=0 cellpadding=10
width="70%" bgcolor="#ffffff">
<tr align="left" valign="top" bgcolor="#ffffff">
<th colspan=2><h1>Risposta automatica:
{$Ticket->Subject}</h1></th>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<td width=70%> </td>
<td width=30%> </td>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<td width=70%>
<h2>
{
my $TextInCarico = '';
if ($Ticket->OwnerObj->Name() eq
'Nobody') {
$TextInCarico = 'Il tuo ticket
non è più in carico a nessuno.';
} else {
$TextInCarico = 'Il tuo ticket
è stato preso in carico da ';
$TextInCarico .=
$Ticket->OwnerObj->RealName;
$TextInCarico .= '.';
}
$TextInCarico;
}
</h2>
<p>
Questo è un messaggio generato
automaticamente in risposta alla presa in
carico del ticket
"{$Ticket->Subject()}". Il ticket è riportato in calce.
<br /><br />
Non è necessario rispondere a questo
messaggio.
Al ticket è stato assegnato il seguente
identificativo:
[{$Ticket->QueueObj->SubjectTag || $rtname}
#{$Ticket->id()}].
<br /><br />
Al fine di gestire correttamente il ticket
è necessario riportare la dicitura
<br /><br />
[{$Ticket->QueueObj->SubjectTag || $rtname}
#{$Ticket->id}]
<br /><br />
nell'oggetto di ogni futuro messaggio
riguardante questo problema.
È sufficiente premere il tasto
"rispondi" per ottenere l'effetto desiderato.
<br /><br />
<b>Grazie<br/>
{$Ticket->QueueObj->CorrespondAddress()}</b>
</p>
</td>
<td bgcolor="#ffffff" width=30%>
<h2>Dettagli ticket:</h2>
<p><small>{$Ticket->Transactions->First->Content()}<br /></small></p>
</td>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<th colspan=2 align="left">
<small>RT for {$rtname}</small>
</th>
</tr>
</table>
</body>
</html>
Content-Type: text/html
Subject: {$Ticket->Subject}
RT-Attach-Message: yes
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{$Ticket->Subject}</title>
</head>
<body bgcolor="#ffffff">
<table align="center" border="1" cellspacing=0 cellpadding=10
width="70%" bgcolor="#ffffff">
<tr align="left" valign="top" bgcolor="#ffffff">
<th colspan=2><h1>{$Ticket->Subject}</h1></th>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<td colspan=2>
<a
href="#risoluzione"><small>Risoluzione</small></a>
<a href="#richiesta"><small>Richiesta
iniziale</small></a>
<a href="#storia"><small>Storia completa del
ticket</small></a>
</td>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<td width=70%>
<a name="risoluzione"><h2>Risoluzione:</h2></a>
<p>
{
my $Transactions = $Ticket->Transactions;
$Transactions->Limit( FIELD => 'Type', VALUE => 'Comment' );
$Transactions->OrderByCols (
{ FIELD => 'Created', ORDER => 'DESC' },
{ FIELD => 'id', ORDER => 'DESC' },
);
my $resolution_comment;
my $CommentObj = $Transactions->First;
if( $CommentObj && $CommentObj->id ) {
$resolution_comment = $CommentObj->Content();
}
$resolution_comment;
}
{
my $res;
my $Transactions = $Ticket->Transactions;
$Transactions->Limit( FIELD => 'Type', VALUE => 'Comment' );
$Transactions->OrderByCols (
{ FIELD => 'Created', ORDER => 'DESC' },
{ FIELD => 'id', ORDER => 'DESC' },
);
my $resolution_comment;
my $CommentObj = $Transactions->First;
if( $CommentObj && $CommentObj->id ) {
my $Attachments = $CommentObj->Attachments;
$Attachments->Limit( FIELD => 'Filename', OPERATOR => '!=', VALUE => '' );
while (my $a = $Attachments->Next) {
$res .= "Allegati:\n" unless ($res);
$res .= " ". $a->Filename;
## $self->TransactionObj->Attach(
## Type => $a->ContentType,
## Charset => $a->OriginalEncoding,
## Data => $a->OriginalContent,
## Filename => Encode::decode_utf8($a->Filename),
## Encoding => '-SUGGEST'
## );
}
}
$res;
}
{
my $signature = '';
my $siginclude = RT->Config->Get('MessageBoxIncludeSignatureOnComment');
if (my $text = $Ticket->OwnerObj->Signature and not $siginclude) {
$signature = "<pre>-- \n". $text . "</pre>";
}
$signature;
}
</p>
<br/>
<hr/>
<a name="richiesta"><h2>Richiesta iniziale:</h2></a>
<p>
{$Ticket->Transactions->First->Content()}
</p>
<br/><br/>
<hr/>
<a name="storia"><h2>Storia completa del ticket:</h2></a>
<pre>
{
use Text::Reform;
my $resolved_message = '';
my $last_content = '';
my $transactions = $Ticket->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'Correspond' );
while (my $transaction = $transactions->Next) {
my $attachments = $transaction->Attachments;
while (my $message = $attachments->Next) {
next unless $message->ContentType =~
m!^(text/plain|message|text$)!i;
my $content = $message->Content;
next unless $content;
next if $last_content eq $content;
$last_content = $content;
my $subject = ($message->Subject || $Ticket->Subject);
my $wrapper = Text::Wrapper->new(columns=>65);
$content = $wrapper->wrap($content);
$resolved_message .= "Subject: ";
$resolved_message .= $subject;
$resolved_message .= "\n";
$resolved_message .= "From: ";
$resolved_message .= $message->CreatorObj->RealName ||
$message->CreatorObj->EmailAddress;
$resolved_message .= "\n";
$resolved_message .= "Time: ";
$resolved_message .= $message->CreatedObj->AsString;
$resolved_message .= "\n";
$resolved_message .= "\n";
$resolved_message .= "$content\n";
$resolved_message .= "------------------------------------------------\n";
}
}
$format = "==>
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[";
$data = $resolved_message;
$resolved_message = form $format, $data;
$resolved_message;
}
</pre>
</td>
<td bgcolor="#ffffff" width=30%>
<h2>Note:</h2>
<p><small>
La richiesta in oggetto è stata evasa.
Per maggiori dettagli leggere il commento di
risoluzione.
<br/><br/>
Se la risoluzione dovesse risultare incompleta
o errata,
rispondendo a questo messaggio il ticket
verrà riaperto.
<br/><br/>
<b>In tutti gli altri casi vi preghiamo di NON
RISPONDERE A QUESTO MESSAGGIO</b>.
<br/><br/>
{$Ticket->OwnerObj->RealName ||
$Ticket->OwnerObj->Name}
</small></p>
</td>
</tr>
<tr align="left" valign="top" bgcolor="#ffffff">
<td colspan=2>
<h3>Informazioni:</h3>
<small>
Non è necessario rispondere a
questo messaggio, a meno di
voler RIAPRIRE il ticket contrassegnato
con l'ID
[{$Ticket->QueueObj->SubjectTag}
#{$Ticket->id}].
<br/><br/>
NOTE:<br/>
- Includere sempre la dicitura
[{$Ticket->QueueObj->SubjectTag} #{$Ticket->id}]
nell'oggetto di ogni futura
corrispondenza riguardante il
presente problema.<br/>
- NON includere il contenuto delle mail
precedenti inviate
da RT (cioè con mittente
"xxx via RT").<br/>
<br/>
<i><b>Nota di riservatezza:</b> Il
presente messaggio non è di natura personale ma inviato
per esigenze lavorative;
lâeventuale messaggio di risposta
potrà essere conosciuto anche da altri soggetti
diversi dallâoriginatore di questo
messaggio per dette esigenze o per controllo
aziendale. Questo messaggio, corredato
dei relativi allegati, contiene
informazioni da considerarsi
strettamente riservate, ed è destinato esclusivamente
al destinatario sopra indicato, il
quale è l'unico autorizzato ad usarlo,
copiarlo e, sotto la propria
responsabilità , diffonderlo.
Chiunque ricevesse questo messaggio per
errore o comunque lo leggesse senza
esserne legittimato è avvertito che
trattenerlo, copiarlo, divulgarlo,
distribuirlo a persone diverse dal
destinatario è severamente proibito, ed è
pregato di rinviarlo immediatamente al
mittente distruggendone l'originale.</i>
</small>
</td>
</tr>
</table>
</body>
</html>