Unverified Commit c45e93f5 authored by colemanw's avatar colemanw Committed by GitHub

Merge pull request #16910 from eileenmcnaughton/conf

Deprecate use of  in OptionGroup::add() function
parents 9d7629be d8efe404
......@@ -31,17 +31,14 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue {
* @param array $params
* Input parameters.
*
* @return object
* @return CRM_Core_DAO_OptionValue
* @throws \CRM_Core_Exception
*/
public static function create($params) {
if (empty($params['id'])) {
self::setDefaults($params);
}
$ids = [];
if (!empty($params['id'])) {
$ids = ['optionValue' => $params['id']];
}
return CRM_Core_BAO_OptionValue::add($params, $ids);
return CRM_Core_BAO_OptionValue::add($params);
}
/**
......@@ -151,9 +148,14 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue {
* deprecated Reference array contains the id.
*
* @return \CRM_Core_DAO_OptionValue
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function add(&$params, $ids = []) {
if (!empty($ids['optionValue']) && empty($params['id'])) {
CRM_Core_Error::deprecatedFunctionWarning('$params[\'id\'] should be set, $ids is deprecated');
}
$id = $params['id'] ?? $ids['optionValue'] ?? NULL;
// CRM-10921: do not reset attributes to default if this is an update
//@todo consider if defaults are being set in the right place. 'dumb' defaults like
......
......@@ -53,7 +53,6 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
['option_group_id' => $this->groupId]
);
$ids = [];
$params = [
'label' => $info->label . ' (' . $info->key . ')',
'value' => $info->typeInfo['reportUrl'],
......@@ -65,7 +64,7 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base {
'is_active' => 1,
];
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
$optionValue = CRM_Core_BAO_OptionValue::add($params);
}
/**
......
......@@ -55,8 +55,7 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base {
'is_active' => 1,
];
$ids = [];
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
$optionValue = CRM_Core_BAO_OptionValue::add($params);
return $optionValue ? TRUE : FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment