From 25a8e8c2bd2d535d2812a36353ac0b5996e14639 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 4 Jul 2018 16:04:35 +1200 Subject: [PATCH] dev/core/issues/228 fix OptionGroup create action to not disable on update --- CRM/Core/BAO/OptionGroup.php | 10 +++------- CRM/Upgrade/Incremental/sql/5.5.alpha1.mysql.tpl | 8 ++++++++ xml/schema/Core/OptionGroup.xml | 5 +++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CRM/Core/BAO/OptionGroup.php b/CRM/Core/BAO/OptionGroup.php index fdc415b5ca..bbabcef8bd 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -88,16 +88,12 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup { * @return object */ public static function add(&$params, $ids = array()) { - if (empty($params['id'])) { - $params['id'] = CRM_Utils_Array::value('optionGroup', $ids); + if (empty($params['id']) && !empty($ids['optionGroup'])) { + CRM_Core_Error::deprecatedFunctionWarning('no $ids array'); + $params['id'] = $ids['optionGroup']; } - - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); - - // action is taken depending upon the mode $optionGroup = new CRM_Core_DAO_OptionGroup(); $optionGroup->copyValues($params);; - $optionGroup->save(); return $optionGroup; } diff --git a/CRM/Upgrade/Incremental/sql/5.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.5.alpha1.mysql.tpl index 937c7beae6..d8f9bd573a 100644 --- a/CRM/Upgrade/Incremental/sql/5.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.5.alpha1.mysql.tpl @@ -1 +1,9 @@ {* file to handle db changes in 5.5.alpha1 during upgrade *} +#https://lab.civicrm.org/dev/core/issues/228 +UPDATE civicrm_option_group SET is_active = 0 WHERE is_active IS NULL; +ALTER TABLE civicrm_option_group MODIFY COLUMN is_active TINYINT(4) NOT NULL DEFAULT 1 COMMENT 'Is this option group active?'; +UPDATE civicrm_option_group SET is_locked = 0 WHERE is_locked IS NULL; +ALTER TABLE civicrm_option_group MODIFY COLUMN is_locked TINYINT(4) NOT NULL DEFAULT 1 COMMENT 'A lock to remove the ability to add new options via the UI.'; +#is_reserved already has a default so is effectively required but let's be explicit. +UPDATE civicrm_option_group SET `is_reserved` = 0 WHERE `is_reserved` IS NULL; +ALTER TABLE civicrm_option_group MODIFY COLUMN `is_reserved` tinyint(4) NOT NULL DEFAULT 1 COMMENT 'Is this a predefined system option group (i.e. it can not be deleted)?'; diff --git a/xml/schema/Core/OptionGroup.xml b/xml/schema/Core/OptionGroup.xml index 013e76dde9..3df4c11d18 100644 --- a/xml/schema/Core/OptionGroup.xml +++ b/xml/schema/Core/OptionGroup.xml @@ -61,6 +61,7 @@ Option Group Is Reserved? boolean 1 + true Is this a predefined system option group (i.e. it can not be deleted)? 1.5 @@ -68,12 +69,16 @@ is_active Option Group Is Active? boolean + 1 + true Is this option group active? 1.5 is_locked Option Group Is Locked + 0 + true boolean A lock to remove the ability to add new options via the UI. 4.5 -- 2.25.1