From 62c41ada4eab37d56aeb806980f9a5d77178c423 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 14 Feb 2020 14:50:18 +1300 Subject: [PATCH] dev/core#1588 Fix regression where empty string is passed to SettingsBag We have a scenario where the checkbox is presented but is optional. This is then in 'params' which is passed through to PropertyBag. The value is equal to '' so it fails to validate when we use it to set the value on the PropertyBag. I don't think we lose anything meaningful by not setting an empty string and it avoids this error so we should merge & release as a regression fix IMHO. If we want to revist then we should do that in master https://lab.civicrm.org/dev/core/issues/1588 --- CRM/Contribute/Form/Contribution/Confirm.php | 1 + Civi/Payment/PropertyBag.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 4d9534b811..a71a646027 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -2020,6 +2020,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr * @param int $contactID * * @return array + * @throws \CRM_Core_Exception */ protected function processFormSubmission($contactID) { if (!isset($this->_params['payment_processor_id'])) { diff --git a/Civi/Payment/PropertyBag.php b/Civi/Payment/PropertyBag.php index afdee0abb6..cb9a6a0fe8 100644 --- a/Civi/Payment/PropertyBag.php +++ b/Civi/Payment/PropertyBag.php @@ -278,9 +278,9 @@ class PropertyBag implements \ArrayAccess { * @param array $data */ public function mergeLegacyInputParams($data) { - $this->legacyWarning("We have merged input params into the property bag for now but please rewrite code to not use this."); + $this->legacyWarning('We have merged input params into the property bag for now but please rewrite code to not use this.'); foreach ($data as $key => $value) { - if ($value !== NULL) { + if ($value !== NULL && $value !== '') { $this->offsetSet($key, $value); } } -- 2.25.1