From c11c73cd3c4b01b416fb4fc181c40b8abca9d808 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 6 Apr 2021 10:18:45 +1200 Subject: [PATCH] E-notice fix on serialized setting We do actually support settings declaring defaults for a serialized field as an array rather than as a serialised string. However, this setting form, if used, will display an e-notice in that case as it will still try to unserialize - this adds a simple check first --- CRM/Admin/Form/SettingTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 61b45298b3..1dac8aadac 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -305,8 +305,8 @@ trait CRM_Admin_Form_SettingTrait { foreach (array_keys($this->_settings) as $setting) { $this->_defaults[$setting] = civicrm_api3('setting', 'getvalue', ['name' => $setting]); $spec = $this->getSettingsMetaData()[$setting]; - if (!empty($spec['serialize'])) { - $this->_defaults[$setting] = CRM_Core_DAO::unSerializeField($this->_defaults[$setting], $spec['serialize']); + if (!empty($spec['serialize']) && !is_array($this->_defaults[$setting])) { + $this->_defaults[$setting] = CRM_Core_DAO::unSerializeField((string) $this->_defaults[$setting], $spec['serialize']); } if ($this->getQuickFormType($spec) === 'CheckBoxes') { $this->_defaults[$setting] = array_fill_keys($this->_defaults[$setting], 1); -- 2.25.1