From 79216b0de49c96a113d5e8edaa491dc657ba6bd5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 17 Feb 2022 16:28:26 -0500 Subject: [PATCH] Mailing - Add `serialize` and `add` to `template_options` field No need for special handling to json_encode the field, the BAO takes care of that automatically when `serialize` is declared. Test coverage in api_v3_MailingTest::testMailerCreateTemplateOptions --- CRM/Mailing/DAO/Mailing.php | 7 ++++--- api/v3/Mailing.php | 3 --- xml/schema/Mailing/Mailing.xml | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index eef22e75d7..219a8c9905 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Mailing/Mailing.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:9815b093c77eedc9aa2c97c338a0e75d) + * (GenCodeChecksum:d9992e7d40fdab9d29f2a093e34aa1cb) */ /** @@ -737,7 +737,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { 'pseudoconstant' => [ 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames', ], - 'add' => NULL, + 'add' => '4.7.16', ], 'template_options' => [ 'name' => 'template_options', @@ -749,7 +749,8 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { 'entity' => 'Mailing', 'bao' => 'CRM_Mailing_BAO_Mailing', 'localizable' => 0, - 'add' => NULL, + 'serialize' => self::SERIALIZE_JSON, + 'add' => '4.7.16', ], 'subject' => [ 'name' => 'subject', diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 650b3e4f83..83bc28b741 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -27,9 +27,6 @@ * @throws \Civi\API\Exception\UnauthorizedException */ function civicrm_api3_mailing_create($params) { - if (isset($params['template_options']) && is_array($params['template_options'])) { - $params['template_options'] = ($params['template_options'] === []) ? '{}' : json_encode($params['template_options']); - } $safeParams = $params; $timestampCheck = TRUE; if (!empty($params['id']) && !empty($params['modified_date'])) { diff --git a/xml/schema/Mailing/Mailing.xml b/xml/schema/Mailing/Mailing.xml index 0cddc59635..f7a9ebb848 100644 --- a/xml/schema/Mailing/Mailing.xml +++ b/xml/schema/Mailing/Mailing.xml @@ -206,12 +206,15 @@ CRM_Mailing_BAO_Mailing::getTemplateTypeNames + 4.7.16 template_options Template Options (JSON) longtext Advanced options used by the email templating system. (JSON encoded) + JSON + 4.7.16 subject -- 2.25.1