CRM-13123 - Add serialization metadata to schema
authorColeman Watts <coleman@civicrm.org>
Fri, 8 Dec 2017 21:52:51 +0000 (16:52 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 14 Dec 2017 22:25:37 +0000 (15:25 -0700)
39 files changed:
CRM/Contact/DAO/Contact.php
CRM/Contact/DAO/Group.php
CRM/Contact/DAO/SavedSearch.php
CRM/Contribute/DAO/ContributionPage.php
CRM/Core/CodeGen/Specification.php
CRM/Core/DAO.php
CRM/Core/DAO/CustomGroup.php
CRM/Core/DAO/Domain.php
CRM/Core/DAO/PrevNextCache.php
CRM/Core/DAO/PrintLabel.php
CRM/Core/DAO/Setting.php
CRM/Core/DAO/UFGroup.php
CRM/Core/DAO/UFJoin.php
CRM/Event/DAO/Participant.php
CRM/Financial/DAO/PaymentProcessor.php
CRM/Member/DAO/MembershipBlock.php
CRM/Pledge/DAO/PledgeBlock.php
CRM/Queue/DAO/QueueItem.php
CRM/Report/DAO/ReportInstance.php
tests/phpunit/CRM/Core/DAOTest.php
xml/schema/Contact/Contact.xml
xml/schema/Contact/Group.xml
xml/schema/Contact/SavedSearch.xml
xml/schema/Contribute/ContributionPage.xml
xml/schema/Core/CustomGroup.xml
xml/schema/Core/Domain.xml
xml/schema/Core/PrevNextCache.xml
xml/schema/Core/PrintLabel.xml
xml/schema/Core/Setting.xml
xml/schema/Core/UFGroup.xml
xml/schema/Core/UFJoin.xml
xml/schema/Cxn/Cxn.xml
xml/schema/Event/Participant.xml
xml/schema/Financial/PaymentProcessor.xml
xml/schema/Member/MembershipBlock.xml
xml/schema/Pledge/PledgeBlock.xml
xml/schema/Queue/QueueItem.xml
xml/schema/Report/ReportInstance.xml
xml/templates/dao.tpl

index 9c738c102fbd0d48529660cce0456aabb0808947..837f0a3cd7e0f7df7bb2964e3a68630870f7be6d 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contact/Contact.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:b1dbc34947126531f2fd11aaa30b14a5)
+ * (GenCodeChecksum:395cdbb5eaf3b1f74fb87f93269d8336)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -442,6 +442,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -709,6 +710,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
           'html' => array(
             'type' => 'Select',
           ) ,
index f3a4ad3091aa1f04c8108c78ccf18431e9ff8fda..f77b220fc6d67af8ee38fd5dea8d6da3277d2e96 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contact/Group.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:4c9dfb678f18129fd9d667de3727dfeb)
+ * (GenCodeChecksum:848664fcd390bd178325b0d991c8e947)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -321,6 +321,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'where_tables' => array(
           'name' => 'where_tables',
@@ -331,6 +332,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'group_type' => array(
           'name' => 'group_type',
@@ -343,6 +345,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
           'pseudoconstant' => array(
             'optionGroupName' => 'group_type',
             'optionEditPath' => 'civicrm/admin/options/group_type',
index f6d87c8da14515031a5f6b693eec660cd429b07d..bfecfb6bbc8e483a5681129915d148cce9c2d8c6 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contact/SavedSearch.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:8e799b35db1b6a38deee5a757d4183c0)
+ * (GenCodeChecksum:0341555885ddaf5dbc8e4d6cfe1d899c)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -146,6 +146,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'mapping_id' => array(
           'name' => 'mapping_id',
@@ -187,6 +188,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'where_tables' => array(
           'name' => 'where_tables',
@@ -197,6 +199,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index 27a9fa5c2c27d155c6cdcef75b3e2026ce7c5080..d26a27bc0ad70771c9ff91c5d3198e1600e54259 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contribute/ContributionPage.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:00d0eb39eb657241b67e9d5b12bc09d8)
+ * (GenCodeChecksum:2bc7d9380c552fe9995f8403f757cd09)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -481,6 +481,15 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
+          'html' => array(
+            'type' => 'Select',
+          ) ,
+          'pseudoconstant' => array(
+            'optionGroupName' => 'recur_frequency_units',
+            'keyColumn' => 'name',
+            'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
+          )
         ) ,
         'is_recur_interval' => array(
           'name' => 'is_recur_interval',
index 7184d738d2bd1c6bad8213aba24de569eaa79483..63119cf49eb5eadfce80ed25c50b95116013af18 100644 (file)
@@ -361,6 +361,7 @@ class CRM_Core_CodeGen_Specification {
     $field['headerPattern'] = $this->value('headerPattern', $fieldXML);
     $field['dataPattern'] = $this->value('dataPattern', $fieldXML);
     $field['uniqueName'] = $this->value('uniqueName', $fieldXML);
+    $field['serialize'] = $this->value('serialize', $fieldXML);
     $field['html'] = $this->value('html', $fieldXML);
     if (!empty($field['html'])) {
       $validOptions = array(
index 503a896e76464152f6d5852ec0626500463cf56a..a15abff3577b58d177e6e18b6872d71c3fb1fc4d 100644 (file)
@@ -64,7 +64,12 @@ class CRM_Core_DAO extends DB_DataObject {
     BULK_INSERT_COUNT = 200,
     BULK_INSERT_HIGH_COUNT = 200,
     QUERY_FORMAT_WILDCARD = 1,
-    QUERY_FORMAT_NO_QUOTES = 2;
+    QUERY_FORMAT_NO_QUOTES = 2,
+    SERIALIZE_SEPARATOR_BOOKEND = 1,
+    SERIALIZE_SEPARATOR_TRIMMED = 2,
+    SERIALIZE_COMMA = 3,
+    SERIALIZE_JSON = 4,
+    SERIALIZE_PHP = 5;
 
   /**
    * Define entities that shouldn't be created or deleted when creating/ deleting
@@ -2593,4 +2598,65 @@ SELECT contact_id
     return TRUE;
   }
 
+  /**
+   * Transform an array to a serialized string for database storage.
+   *
+   * @param array|NULL $value
+   * @param $serializationType
+   * @return string|NULL
+   */
+  public static function serializeField($value, $serializationType) {
+    if ($value === NULL) {
+      return NULL;
+    }
+    switch ($serializationType) {
+      case self::SERIALIZE_SEPARATOR_BOOKEND:
+        return $value === array() ? '' : CRM_Utils_Array::implodePadded($value);
+
+      case self::SERIALIZE_SEPARATOR_TRIMMED:
+        return is_array($value) ? implode(self::VALUE_SEPARATOR, $value) : $value;
+
+      case self::SERIALIZE_COMMA:
+        return is_array($value) ? implode(',', $value) : $value;
+
+      case self::SERIALIZE_JSON:
+        return is_array($value) ? json_encode($value) : $value;
+
+      case self::SERIALIZE_PHP:
+        return is_array($value) ? serialize($value) : $value;
+    }
+  }
+
+  /**
+   * Transform a serialized string from the database into an array.
+   *
+   * @param string|null $value
+   * @param $serializationType
+   * @return array|null
+   */
+  public static function unSerializeField($value, $serializationType) {
+    if ($value === NULL) {
+      return NULL;
+    }
+    if ($value === '') {
+      return array();
+    }
+    switch ($serializationType) {
+      case self::SERIALIZE_SEPARATOR_BOOKEND:
+        return (array) CRM_Utils_Array::explodePadded($value);
+
+      case self::SERIALIZE_SEPARATOR_TRIMMED:
+        return explode(self::VALUE_SEPARATOR, trim($value));
+
+      case self::SERIALIZE_COMMA:
+        return explode(',', trim(str_replace(', ', '', $value)));
+
+      case self::SERIALIZE_JSON:
+        return strlen($value) ? json_decode($value, TRUE) : array();
+
+      case self::SERIALIZE_PHP:
+        return strlen($value) ? unserialize($value) : array();
+    }
+  }
+
 }
index 1c45988a6814207ec62a94a0501d9ec43cfb4dbb..48f3b186fde147fc4783060c017ad049f639b2ae 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/CustomGroup.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:5b2dac3266e0184dc4eaa6de10c9d401)
+ * (GenCodeChecksum:4b960c311aed67174e9c55901ba3993b)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -276,6 +276,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
         ) ,
         'style' => array(
           'name' => 'style',
index b59999af9f6b9188c32ca73dfbcf98da7f0a1321..9a7adf6461f44e0506ed638b5e8b4612569954f7 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/Domain.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:50edefeb24aa64d2125df018985cd701)
+ * (GenCodeChecksum:7bc078fa4adebf142c73c95fab321f25)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -173,15 +173,11 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Domain Configuration') ,
           'description' => 'Backend configuration.',
-          'rows' => 20,
-          'cols' => 80,
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
           'localizable' => 0,
-          'html' => array(
-            'type' => 'TextArea',
-          ) ,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'version' => array(
           'name' => 'version',
@@ -221,15 +217,11 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Language Customizations') ,
           'description' => 'Locale specific string overrides',
-          'rows' => 20,
-          'cols' => 80,
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
           'localizable' => 0,
-          'html' => array(
-            'type' => 'TextArea',
-          ) ,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index 7ff6035743ffa782fb1d8d24d0dfd2adbd85a7bf..0c5af39cc5948c64be153a06b8547861b2388bbc 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/PrevNextCache.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:edf9dd4b38ca08a34dbc6990ac954af2)
+ * (GenCodeChecksum:cfce4435348e53ba9941ce5ed223c05b)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -170,6 +170,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'is_selected' => array(
           'name' => 'is_selected',
index c2e379a7885277744e5d1de16889335fa8425aff..59847d370481e52a6e62510a341359af3d385743 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/PrintLabel.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:af33d193b72fd8c8bf260c0625c7acf6)
+ * (GenCodeChecksum:60a1aaca1bbf19fe5b752afa03e8fd34)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -233,6 +233,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_JSON,
         ) ,
         'is_default' => array(
           'name' => 'is_default',
index 7648107cb66b9307d389b287e343f4a57b3d2c17..4449695e02bc6db9f078bbef62d51c2a63443971 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/Setting.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:a9b0b7aaf6ae42696ce402c1ff9acb89)
+ * (GenCodeChecksum:5aa73137509e3760555c0f3d1d746b05)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -166,6 +166,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'domain_id' => array(
           'name' => 'domain_id',
index ced384ae3154e180ba22a1598e93772baeb4cef5..e957729b3ad4b6f86387d26587deb1ef5d5cc470 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/UFGroup.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d87b52f7baf5aa4e4ccaf26c6e7acabc)
+ * (GenCodeChecksum:2c943baba637124caec29c4aefeb9228)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -268,6 +268,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
         ) ,
         'title' => array(
           'name' => 'title',
index a85d2e6e5e732d8c9f5048a9c84211ea2e0edd6b..d28ebd759531aca189131ab7728933f3552e8f75 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/UFJoin.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:fde4a7125f1dd6d9e5081b534f151db6)
+ * (GenCodeChecksum:141d4903e67ac8bce639e3db9c7ba875)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -229,6 +229,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_JSON,
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index 9142d60ba405878a09f8daefc25597a3dccbc8dc..1bbcdaa8424a5b03579f3158f3171d9b133dc121 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Event/Participant.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:89138cc7e79eac37b1b499084956428f)
+ * (GenCodeChecksum:444d0ee69773ce242341f8544e192087)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -292,6 +292,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'entity' => 'Participant',
           'bao' => 'CRM_Event_BAO_Participant',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -352,6 +353,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'entity' => 'Participant',
           'bao' => 'CRM_Event_BAO_Participant',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
         ) ,
         'participant_is_test' => array(
           'name' => 'is_test',
index c585f1945d647cecfabf09a316f1dc7eecdcefee..f5546564409cc20e2302e467dd246ef8843d8d5c 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Financial/PaymentProcessor.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:223b44e4b9e2994f724d2dbd79f575e4)
+ * (GenCodeChecksum:5a228384ec4b687a6961505b12d40512)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -482,6 +482,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_JSON,
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index f20ca244a47d19535ae657fa6736f6bfc13df8ce..db4feda2930a10ea7b4b02cd84f46e8da92866a6 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Member/MembershipBlock.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:3ee510fab11783acf6ee994f090436f6)
+ * (GenCodeChecksum:b99880f7b9c20c98f428dd694d8264ba)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -204,6 +204,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'membership_type_default' => array(
           'name' => 'membership_type_default',
index a8b3fa840587da13df6ef990344f16643666c009..e6cfa9fdcef2245a705ca1a8b519bd59740f2228 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Pledge/PledgeBlock.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:27ee8365a58c51c15fcf0ae78b2f5f32)
+ * (GenCodeChecksum:630f1a7378136b8cc3edcd82a96279d6)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -190,6 +190,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
         ) ,
         'is_pledge_interval' => array(
           'name' => 'is_pledge_interval',
index 8f688be7085bb980b3c9a158f9e6d84fc9d5f7cd..90889d85e0b9f1d12c556f78d46f6d1d37b0e93a 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Queue/QueueItem.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:6ca85e3a41502dda3e60a1c53a83c67f)
+ * (GenCodeChecksum:9049b4828c213985dea2180555f28568)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -79,7 +79,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
    */
   public $release_time;
   /**
-   * Serialized queue
+   * Serialized queue data
    *
    * @var text
    */
@@ -168,12 +168,13 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
         'data' => array(
           'name' => 'data',
           'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Queue item datas') ,
-          'description' => 'Serialized queue',
+          'title' => ts('Queue item data') ,
+          'description' => 'Serialized queue data',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
index ee3f06b0f8b7b5b4ac943d924152fe2bb840d7a9..7ba08fad414a38ebabcbdd70f2f07ab7b982b9f9 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Report/ReportInstance.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:e28abdd2a3696c4a6072dfbfd4f54d68)
+ * (GenCodeChecksum:09ffdd1693f38f5790d4c9c00d3c5d2f)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -356,6 +356,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_PHP,
         ) ,
         'is_active' => array(
           'name' => 'is_active',
index b381daf2157a154ec2fd988b90a990d463102a80..399ecb6e40ba0e4755eba35037fd85bcf6456003 100644 (file)
@@ -392,4 +392,45 @@ class CRM_Core_DAOTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * @return array
+   */
+  public function serializationMethods() {
+    $constants = array();
+    $simpleData = array(
+      NULL,
+      array('Foo', 'Bar', '3', '4', '5'),
+      array(),
+      array('0'),
+    );
+    $complexData = array(
+      array(
+        'foo' => 'bar',
+        'baz' => array('1', '2', '3', array('one', 'two')),
+        '3' => '0',
+      ),
+    );
+    $daoInfo = new ReflectionClass('CRM_Core_DAO');
+    foreach ($daoInfo->getConstants() as $constant => $val) {
+      if ($constant == 'SERIALIZE_JSON' || $constant == 'SERIALIZE_PHP') {
+        $constants[] = array($val, array_merge($simpleData, $complexData));
+      }
+      elseif (strpos($constant, 'SERIALIZE_') === 0) {
+        $constants[] = array($val, $simpleData);
+      }
+    }
+    return $constants;
+  }
+
+  /**
+   * @dataProvider serializationMethods
+   */
+  public function testFieldSerialization($method, $sampleData) {
+    foreach ($sampleData as $value) {
+      $serialized = CRM_Core_DAO::serializeField($value, $method);
+      $newValue = CRM_Core_DAO::unSerializeField($serialized, $method);
+      $this->assertEquals($value, $newValue);
+    }
+  }
+
 }
index 76acad1d61b9c8843caef2904bbc7700d1dc23ef..e6a596c6701c7ad658a4693f37a9272423e31155 100644 (file)
@@ -64,6 +64,7 @@
       <type>Select</type>
       <multiple>1</multiple>
     </html>
+    <serialize>SEPARATOR_BOOKEND</serialize>
     <add>1.5</add>
   </field>
   <index>
     </pseudoconstant>
     <html>
       <type>Select</type>
+      <multiple>1</multiple>
     </html>
+    <serialize>SEPARATOR_BOOKEND</serialize>
   </field>
   <index>
     <name>index_preferred_communication_method</name>
index fb9c1bd67125de95bb36ce95a47d1919cb3ad444..68ad6eb3f49736e28130f47d391a831f61f1f287 100644 (file)
     <type>text</type>
     <title>Tables For Select Clause</title>
     <comment>the tables to be included in a select data</comment>
+    <serialize>PHP</serialize>
     <add>1.6</add>
   </field>
   <field>
     <type>text</type>
     <title>Tables For Where Clause</title>
     <comment>the tables to be included in the count statement</comment>
+    <serialize>PHP</serialize>
     <add>1.6</add>
   </field>
   <field>
     <pseudoconstant>
       <optionGroupName>group_type</optionGroupName>
     </pseudoconstant>
+    <serialize>SEPARATOR_BOOKEND</serialize>
     <add>1.9</add>
   </field>
   <field>
index f35330c73cf9a9840eefab0d0b58ee18498993af..4da353078754c92a7bce91671b065f332410deac 100644 (file)
@@ -33,6 +33,7 @@
     <type>text</type>
     <import>true</import>
     <comment>Submitted form values for this search</comment>
+    <serialize>PHP</serialize>
     <add>1.1</add>
   </field>
   <field>
@@ -75,6 +76,7 @@
     <type>text</type>
     <title>Select Tables</title>
     <comment>the tables to be included in a select data</comment>
+    <serialize>PHP</serialize>
     <add>1.6</add>
   </field>
   <field>
@@ -82,6 +84,7 @@
     <type>text</type>
     <title>Where Tables</title>
     <comment>the tables to be included in the count statement</comment>
+    <serialize>PHP</serialize>
     <add>1.6</add>
   </field>
 </table>
index 7c821d01776ab7a9295985a9bcee242f2290bdd1..ace8c0f500bb5685ed5a1d29d6d9a69d769f8681 100644 (file)
     <type>varchar</type>
     <length>128</length>
     <comment>Supported recurring frequency units.</comment>
+    <pseudoconstant>
+      <optionGroupName>recur_frequency_units</optionGroupName>
+      <keyColumn>name</keyColumn>
+    </pseudoconstant>
+    <html>
+      <type>Select</type>
+      <multiple>1</multiple>
+    </html>
+    <serialize>SEPARATOR_TRIMMED</serialize>
     <add>2.1</add>
   </field>
   <field>
index a9bdbdba801b36f7587cf46fcc9ef33370cfca51..de3a4d70f168cf8e0f9332820d2ec0c0d0e95aad 100644 (file)
@@ -69,6 +69,7 @@
     <title>Custom Group Subtype</title>
     <length>255</length>
     <comment>linking custom group for dynamic object</comment>
+    <serialize>SEPARATOR_BOOKEND</serialize>
     <add>1.6</add>
   </field>
   <field>
index c3a602031307a7af0ff3a889fc91fd5ec2ee87b1..f9478785599e4cdf9827074cda8df4e0d0496a17 100644 (file)
     <type>text</type>
     <title>Domain Configuration</title>
     <comment>Backend configuration.</comment>
-    <html>
-      <type>TextArea</type>
-      <rows>20</rows>
-      <cols>80</cols>
-    </html>
+    <serialize>PHP</serialize>
     <add>1.6</add>
   </field>
   <field>
     <type>text</type>
     <title>Language Customizations</title>
     <comment>Locale specific string overrides</comment>
-    <html>
-      <type>TextArea</type>
-      <rows>20</rows>
-      <cols>80</cols>
-    </html>
+    <serialize>PHP</serialize>
     <add>3.2</add>
   </field>
 </table>
index 7c74a19cee3757458d52d0ce529bcd9a3161161c..5fda09bd84eb7e62c5ad7b2d314277c8687983db 100644 (file)
@@ -54,6 +54,7 @@
     <title>Prev Next Data</title>
     <type>longtext</type>
     <comment>cached snapshot of the serialized data</comment>
+    <serialize>PHP</serialize>
     <add>3.4</add>
   </field>
   <field>
index b5e2ee0ec52e772c54cfa6fd2f2e13c21d380f4d..06b1684163075f30e492ff381d42f08334a509cf 100644 (file)
@@ -71,6 +71,7 @@
     <type>longtext</type>
     <comment>contains json encode configurations options</comment>
     <add>4.4</add>
+    <serialize>JSON</serialize>
   </field>
   <field>
     <name>is_default</name>
index d2865d352b245cb719a81d9fb358e37e7e439c3a..0a5263fab71c3b0da36a90ab03491c1c367c7da3 100644 (file)
@@ -46,6 +46,7 @@
     <name>value</name>
     <type>text</type>
     <comment>data associated with this group / name combo</comment>
+    <serialize>PHP</serialize>
     <add>4.1</add>
   </field>
   <field>
index 9e2f6faf4de9658d446a4cceb1ac0f74e18502ad..69784bf2249f7a6305df1f4196a5c2f5b3c5a4c1 100644 (file)
@@ -34,6 +34,7 @@
     <length>255</length>
     <import>true</import>
     <comment>This column will store a comma separated list of the type(s) of profile fields.</comment>
+    <serialize>SEPARATOR_TRIMMED</serialize>
     <add>2.1</add>
   </field>
   <field>
index 54b291fd0838ae60b9c357c241f4a1d08262d85b..368a3e0c0a3070fc2119c52fda6693076374b047 100644 (file)
     <title>Profile Use Data</title>
     <type>longtext</type>
     <comment>Json serialized array of data used by the ufjoin.module</comment>
+    <serialize>JSON</serialize>
     <add>4.5</add>
   </field>
 </table>
index c432f0915fd80c55227837a159347c7100555bd1..f8d7ee2c22ed139f68ddfa23bb4348b20b992dbc 100644 (file)
@@ -72,6 +72,7 @@
     <name>options</name>
     <type>text</type>
     <comment>Options for the service (JSON)</comment>
+    <serialize>JSON</serialize>
     <add>4.6</add>
   </field>
   
index b35eb253b89d419bd77fccb0f856c864b6897759..5d341014f22ee4dd94b7483b5e7ae85659100ce0 100644 (file)
@@ -95,7 +95,9 @@
     </pseudoconstant>
     <html>
       <type>Select</type>
+      <multiple>1</multiple>
     </html>
+    <serialize>SEPARATOR_TRIMMED</serialize>
     <headerPattern>/(participant.)?(role)$/i</headerPattern>
     <import>true</import>
     <type>varchar</type>
     <headerPattern>/^(f(ee\s)?level)$/i</headerPattern>
     <type>text</type>
     <import>true</import>
+    <serialize>SEPARATOR_BOOKEND</serialize>
     <comment>Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that
       we store the label value and not the key
     </comment>
index 05e94fca44471935a1a4ff34525e0d68746284d9..0538fcc6983d9897b4019bc1cb3595a527819120 100644 (file)
     <type>text</type>
     <default>NULL</default>
     <comment>array of accepted credit card types</comment>
+    <serialize>JSON</serialize>
     <add>4.7</add>
   </field>
 </table>
index b78cea9cd57d70265872a6325d858f627f297606..89503bb66b1f5d4e0098f7b1f2e7b95aa4b00be1 100644 (file)
@@ -47,6 +47,7 @@
     <type>varchar</type>
     <length>1024</length>
     <comment>Membership types to be exposed by this block</comment>
+    <serialize>PHP</serialize>
     <add>1.5</add>
      <!-- changed from varchar 255 to 1024 in 4.6 beta 2 -->
     <change>4.6</change>
index 5467caed27e5778f8b0557ce953f697e64d6cd50..6dd3b8a659ce46e0618e632e1e635909a044dd8a 100644 (file)
@@ -50,6 +50,7 @@
     <type>varchar</type>
     <length>128</length>
     <comment>Delimited list of supported frequency units</comment>
+    <serialize>SEPARATOR_TRIMMED</serialize>
     <add>2.1</add>
   </field>
   <field>
index cbbb20de3e7a5c0d607eb99876364d109a5dc5cb..e67bca990a07ec5b4b59cee1f94f5f83a09eb685 100644 (file)
 
   <field>
     <name>data</name>
-    <title>Queue item datas</title>
+    <title>Queue item data</title>
     <type>text</type>
-    <comment>Serialized queue</comment>
+    <comment>Serialized queue data</comment>
+    <serialize>PHP</serialize>
   </field>
   <index>
     <name>index_queueids</name>
index 6b556a445a127cc46e53b55a72e7cd7f74219b4c..9961b9028ef46fa56cf9ad7d97b55abef68ca5f5 100644 (file)
     <type>text</type>
     <import>true</import>
     <comment>Submitted form values for this report</comment>
+    <serialize>PHP</serialize>
     <add>2.2</add>
   </field>
   <field>
index 4ba882ad1e69bb0d7b99668336052d00ec369ba8..4d7174d7ed4020f11bf3e424cb4e0dc93c0db7d9 100644 (file)
@@ -170,7 +170,10 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
 
 {if $field.FKClassName}
                       'FKClassName' => '{$field.FKClassName}',
-{/if} {* field.FKClassName *}
+{/if}
+{if $field.serialize}
+  'serialize' => self::SERIALIZE_{$field.serialize|strtoupper},
+{/if}
 {if $field.html}
   {assign var=htmlOptions value=$field.html}
   'html' => array(