[freeside-commits] branch FREESIDE_2_3_BRANCH updated. dc8da661243bf26a0a3c2471651e581d2d846a74

Mark Wells mark at 420.am
Mon Jul 9 17:02:09 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  dc8da661243bf26a0a3c2471651e581d2d846a74 (commit)
      from  94376ab21b2b7c7a5ab516e5c11db94f87bf6639 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dc8da661243bf26a0a3c2471651e581d2d846a74
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Jul 9 17:01:47 2012 -0700

    stop upgrade from corrupting message templates, #18406

diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 57d0004..b88e13a 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -654,10 +654,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;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/msg_template.pm |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list