Skip to content

Commit

Permalink
OptionValue - Fix checking if domain is set
Browse files Browse the repository at this point in the history
Fixes a bug introduced in civicrm#19970
  • Loading branch information
colemanw committed Nov 18, 2021
1 parent 6272f9f commit b1a6388
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CRM/Core/BAO/OptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public static function add(&$params, $ids = []) {
$optionValue->copyValues($params);

$isDomainOptionGroup = in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups);
if (empty($params['domain_id']) && $isDomainOptionGroup) {
// When creating a new option for a group that requires a domain, set default domain
if ($isDomainOptionGroup && empty($params['id']) && (empty($params['domain_id']) || CRM_Utils_System::isNull($params['domain_id']))) {
$optionValue->domain_id = CRM_Core_Config::domainID();
}

Expand All @@ -192,7 +193,7 @@ public static function add(&$params, $ids = []) {
$p = [1 => [$params['option_group_id'], 'Integer']];

// Limit update by domain of option
$domain = $optionValue->domain_id ?? NULL;
$domain = CRM_Utils_System::isNull($optionValue->domain_id) ? NULL : $optionValue->domain_id;
if (!$domain && $id && $isDomainOptionGroup) {
$domain = CRM_Core_DAO::getFieldValue(__CLASS__, $id, 'domain_id');
}
Expand Down

0 comments on commit b1a6388

Please sign in to comment.