From 1f865dbb9e77744eed725b51698a654c7bb7df49 Mon Sep 17 00:00:00 2001 From: Bob Silvern Date: Sun, 5 Jun 2022 14:47:47 -0700 Subject: [PATCH] dev/core#3495 - Advanced Search - Prevent array fields from getting trashed Correctly handle those field values which are arrays, e.g. ['LIKE' => 'field-value'], rather than strings. --- CRM/Core/Form/Search.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index 480986ba66..2af67614c9 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -332,7 +332,11 @@ class CRM_Core_Form_Search extends CRM_Core_Form { foreach ($fields as $fieldName => $field) { if (!empty($this->_formValues[$fieldName]) && empty($field['options']) && empty($field['pseudoconstant'])) { if (in_array($field['type'], [CRM_Utils_Type::T_STRING, CRM_Utils_Type::T_TEXT])) { - $this->_formValues[$fieldName] = ['LIKE' => CRM_Contact_BAO_Query::getWildCardedValue(TRUE, 'LIKE', trim($this->_formValues[$fieldName]))]; + $val = $this->_formValues[$fieldName]; + if (is_array($val)) { + $val = $val['LIKE']; + } + $this->_formValues[$fieldName] = ['LIKE' => CRM_Contact_BAO_Query::getWildCardedValue(TRUE, 'LIKE', trim($val))]; } } } -- 2.25.1