From: eileen Date: Mon, 5 Apr 2021 22:18:45 +0000 (+1200) Subject: E-notice fix on serialized setting X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c11c73cd3c4b01b416fb4fc181c40b8abca9d808;p=civicrm-core.git 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 --- 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);