Trim form values when adding LIKE operator
authoreileen <emcnaughton@wikimedia.org>
Wed, 11 Sep 2019 01:33:36 +0000 (13:33 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 11 Sep 2019 01:33:36 +0000 (13:33 +1200)
This is more consistent with previous behaviour - ie 'info@civicrm.org' AND 'info@civicrm.org ' should work.

CRM/Core/Form/Search.php

index 919f43848ccca7e111587fd12482e48266f01618..7fab1da759fb27a1949f9767420c11dfa9982948 100644 (file)
@@ -321,7 +321,7 @@ 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', $this->_formValues[$fieldName])];
+            $this->_formValues[$fieldName] = ['LIKE' => CRM_Contact_BAO_Query::getWildCardedValue(TRUE, 'LIKE', trim($this->_formValues[$fieldName]))];
           }
         }
       }