diff options
author | Mark Wells <mark@freeside.biz> | 2012-07-09 17:02:49 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-07-09 17:02:49 -0700 |
commit | 8ca531ca72ddffcc3561813bdd2f12f07b5911ce (patch) | |
tree | 8d1c84a983dba489cd04738d319ba92f5437d1f3 /FS/FS/msg_template.pm | |
parent | a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 (diff) |
stop upgrade from corrupting message templates, #18406
Diffstat (limited to 'FS/FS/msg_template.pm')
-rw-r--r-- | FS/FS/msg_template.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index ffb4f52..cac7fe5 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -678,10 +678,20 @@ sub _upgrade_data { if ( $msg_template->subject || $msg_template->body ) { # create new default content my %content; - foreach ('subject','body') { - $content{$_} = $msg_template->$_; - $msg_template->setfield($_, ''); + $content{subject} = $msg_template->subject; + $msg_template->set('subject', ''); + + # work around obscure Pg/DBD bug + # https://rt.cpan.org/Public/Bug/Display.html?id=60200 + # (though the right fix is to upgrade DBD) + my $body = $msg_template->body; + if ( $body =~ /^x([0-9a-f]+)$/ ) { + # there should be no real message templates that look like that + warn "converting template body to TEXT\n"; + $body = pack('H*', $1); } + $content{body} = $body; + $msg_template->set('body', ''); my $error = $msg_template->replace(%content); die $error if $error; |