From: eileen Date: Mon, 29 Jan 2018 22:11:53 +0000 (+1300) Subject: CRM-21707 increase testing / use of serialization metadata. Add deprecated when bypassed X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a8496135ed68bb6048be652e8313d1e8cae136e7;p=civicrm-core.git CRM-21707 increase testing / use of serialization metadata. Add deprecated when bypassed --- diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 5ab5d76d52..f821036b16 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -647,6 +647,9 @@ class CRM_Core_DAO extends DB_DataObject { $allNull = FALSE; } else { + if (!$serializeArrays && is_array($pValue) && !empty($value['serialize'])) { + Civi::log()->warning(ts('use copyParams to serialize arrays (' . __CLASS__ . '.' . $name . ')'), ['civi.tag' => 'deprecated']); + } $this->$dbName = $pValue; $allNull = FALSE; } diff --git a/CRM/Member/BAO/MembershipBlock.php b/CRM/Member/BAO/MembershipBlock.php index 921735ba03..eb32779f7b 100644 --- a/CRM/Member/BAO/MembershipBlock.php +++ b/CRM/Member/BAO/MembershipBlock.php @@ -53,7 +53,7 @@ class CRM_Member_BAO_MembershipBlock extends CRM_Member_DAO_MembershipBlock { $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params); $dao = new CRM_Member_DAO_MembershipBlock(); - $dao->copyValues($params); + $dao->copyValues($params, TRUE); $dao->id = CRM_Utils_Array::value('id', $params); $dao->save(); CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao); diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index fd0096a203..33cb7ab1cd 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -78,7 +78,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { } $instance = new CRM_Report_DAO_ReportInstance(); - $instance->copyValues($params); + $instance->copyValues($params, TRUE); if (CRM_Core_Config::singleton()->userFramework == 'Joomla') { $instance->permission = 'null'; diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index efb57a26d5..7e5e9eb69e 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -1356,6 +1356,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'id' => $entity['id'], $field => isset($entity[$field]) ? $entity[$field] : NULL, ); + if (!empty($specs['serialize'])) { + $updateParams[$field] = $entity[$field] = (array) $specs['serialize']; + } if (isset($updateParams['financial_type_id']) && in_array($entityName, array('Grant'))) { //api has special handling on these 2 fields for backward compatibility reasons $entity['contribution_type_id'] = $updateParams['financial_type_id']; @@ -1377,6 +1380,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ); $checkEntity = $this->callAPISuccess($entityName, 'getsingle', $checkParams); + if (!empty($specs['serialize']) && !is_array($checkEntity[$field])) { + // Put into serialized format for comparison if 'get' has not returned serialized. + $entity[$field] = CRM_Core_DAO::serializeField($checkEntity[$field], $specs['serialize']); + } $this->assertAPIArrayComparison($entity, $checkEntity, array(), "checking if $fieldName was correctly updated\n" . print_r(array( 'update-params' => $updateParams,