The $serializeArrays parameter was transitional and is now always enabled.
Passing $params by reference was unnecessary and has been removed.
Renamed a few variables for readability.
}
}
$group = new CRM_Contact_BAO_Group();
- $group->copyValues($params, TRUE);
+ $group->copyValues($params);
if (empty($params['id']) &&
!$nameParam
*/
public static function create(&$params) {
$savedSearch = new CRM_Contact_DAO_SavedSearch();
- $savedSearch->copyValues($params, TRUE);
+ $savedSearch->copyValues($params);
$savedSearch->save();
return $savedSearch;
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'Domain', CRM_Utils_Array::value('id', $params), $params);
$domain = new CRM_Core_DAO_Domain();
- $domain->copyValues($params, TRUE);
+ $domain->copyValues($params);
$domain->save();
CRM_Utils_Hook::post($hook, 'Domain', $domain->id, $domain);
return $domain;
'column_number' => $colCnt,
], $v);
$saveMappingField = new CRM_Core_DAO_MappingField();
- $saveMappingField->copyValues($saveMappingParams, TRUE);
+ $saveMappingField->copyValues($saveMappingParams);
$saveMappingField->save();
$colCnt++;
}
}
$dao = new CRM_Core_DAO_UFJoin();
- $dao->copyValues($params, TRUE);
+ $dao->copyValues($params);
if ($params['uf_group_id']) {
$dao->save();
}
* that belong to this object and initialize the object with said values
*
* @param array $params
- * (reference ) associative array of name/value pairs.
- * @param bool $serializeArrays
- * Should arrays that are passed in be serialised according to the metadata.
- * Eventually this should be always true / gone, but in the interests of caution
- * it is being grandfathered in. In general an array is not valid on the DAO
- * but there may be instances where this function is called & then some handling
- * takes place on the would-be array.
+ * Array of name/value pairs to save.
*
* @return bool
* Did we copy all null values into the object
*/
- public function copyValues(&$params, $serializeArrays = FALSE) {
- $fields = $this->fields();
+ public function copyValues($params) {
$allNull = TRUE;
- foreach ($fields as $name => $value) {
- $dbName = $value['name'];
+ foreach ($this->fields() as $uniqueName => $field) {
+ $dbName = $field['name'];
if (array_key_exists($dbName, $params)) {
- $pValue = $params[$dbName];
+ $value = $params[$dbName];
$exists = TRUE;
}
- elseif (array_key_exists($name, $params)) {
- $pValue = $params[$name];
+ elseif (array_key_exists($uniqueName, $params)) {
+ $value = $params[$uniqueName];
$exists = TRUE;
}
else {
// if there is no value then make the variable NULL
if ($exists) {
- if ($pValue === '') {
+ if ($value === '') {
$this->$dbName = 'null';
}
- elseif ($serializeArrays && is_array($pValue) && !empty($value['serialize'])) {
- $this->$dbName = CRM_Core_DAO::serializeField($pValue, $value['serialize']);
+ elseif (is_array($value) && !empty($field['serialize'])) {
+ $this->$dbName = CRM_Core_DAO::serializeField($value, $field['serialize']);
$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']);
- }
- $maxLength = CRM_Utils_Array::value('maxlength', $value);
- if (!is_array($pValue) && $maxLength && mb_strlen($pValue) > $maxLength
- && empty($value['pseudoconstant'])
- ) {
- Civi::log()->warning(ts('A string for field $dbName has been truncated. The original string was %1', [CRM_Utils_Type::escape($pValue, 'String')]));
+ $maxLength = CRM_Utils_Array::value('maxlength', $field);
+ if (!is_array($value) && $maxLength && mb_strlen($value) > $maxLength && empty($field['pseudoconstant'])) {
+ Civi::log()->warning(ts('A string for field $dbName has been truncated. The original string was %1', [CRM_Utils_Type::escape($value, 'String')]));
// The string is too long - what to do what to do? Well losing data is generally bad so lets' truncate
- $pValue = CRM_Utils_String::ellipsify($pValue, $maxLength);
+ $value = CRM_Utils_String::ellipsify($value, $maxLength);
}
- $this->$dbName = $pValue;
+ $this->$dbName = $value;
$allNull = FALSE;
}
}
CRM_Utils_Hook::pre($op, 'MailingJob', CRM_Utils_Array::value('id', $params), $params);
$jobDAO = new CRM_Mailing_BAO_MailingJob();
- $jobDAO->copyValues($params, TRUE);
+ $jobDAO->copyValues($params);
$jobDAO->save();
if (!empty($params['mailing_id']) && empty('is_calling_function_updated_to_reflect_deprecation')) {
CRM_Mailing_BAO_Mailing::getRecipients($params['mailing_id']);
$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, TRUE);
+ $dao->copyValues($params);
$dao->id = CRM_Utils_Array::value('id', $params);
$dao->save();
CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao);
}
$instance = new CRM_Report_DAO_ReportInstance();
- $instance->copyValues($params, TRUE);
+ $instance->copyValues($params);
if (CRM_Core_Config::singleton()->userFramework == 'Joomla') {
$instance->permission = 'null';
\CRM_Utils_Hook::pre($hook, $this->getEntityName(), $params['id'] ?? NULL, $params);
/** @var \CRM_Core_DAO $instance */
$instance = new $baoName();
- $instance->copyValues($params, TRUE);
+ $instance->copyValues($params);
$instance->save();
\CRM_Utils_Hook::post($hook, $this->getEntityName(), $instance->id, $instance);
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $dao_name();
- $instance->copyValues($params, TRUE);
+ $instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);