Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionValue - Use DB defaults instead of setting them in BAO::add #17170

Merged
merged 1 commit into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions CRM/Core/BAO/OptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,9 @@ public static function add(&$params, $ids = []) {
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
// these would be usefully set @ the api layer so they are visible to api users
// complex defaults like the domain id below would make sense in the setDefauls function
// but unclear what other ways this function is being used
if (!$id) {
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
$params['is_optgroup'] = CRM_Utils_Array::value('is_optgroup', $params, FALSE);
$params['filter'] = CRM_Utils_Array::value('filter', $params, FALSE);
}

// Update custom field data to reflect the new value
elseif (isset($params['value'])) {
if ($id && isset($params['value'])) {
CRM_Core_BAO_CustomOption::updateValue($id, $params['value']);
}

Expand Down
3 changes: 2 additions & 1 deletion CRM/Core/DAO/OptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/OptionValue.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:c58b4d38fe97741293f8bc5ae5b64e98)
* (GenCodeChecksum:7aa11987c26800632c3798b4cfce95c1)
*/

/**
Expand Down Expand Up @@ -281,6 +281,7 @@ public static function &fields() {
'title' => ts('Filter'),
'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
'where' => 'civicrm_option_value.filter',
'default' => 'NULL',
'table_name' => 'civicrm_option_value',
'entity' => 'OptionValue',
'bao' => 'CRM_Core_BAO_OptionValue',
Expand Down
2 changes: 2 additions & 0 deletions CRM/Upgrade/Incremental/sql/5.26.alpha1.mysql.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{* file to handle db changes in 5.26.alpha1 during upgrade *}

ALTER TABLE civicrm_option_value MODIFY COLUMN `filter` int unsigned DEFAULT NULL COMMENT 'Bitwise logic can be used to create subsets of options within an option_group for different uses.';

UPDATE civicrm_contact SET is_deceased = 0 WHERE is_deceased IS NULL;
ALTER TABLE civicrm_contact MODIFY COLUMN is_deceased TINYINT NOT NULL DEFAULT 0;

Expand Down
1 change: 1 addition & 0 deletions xml/schema/Core/OptionValue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<field>
<name>filter</name>
<type>int unsigned</type>
<default>NULL</default>
<comment>Bitwise logic can be used to create subsets of options within an option_group for different uses.</comment>
<add>1.5</add>
</field>
Expand Down