From: monishdeb Date: Tue, 20 Oct 2015 08:23:49 +0000 (+0530) Subject: CRM-17422 fix - Change in custom field search behaviour impacting on performance X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c995043caeb5a5e7175882fac77fa44c893575a2;p=civicrm-core.git CRM-17422 fix - Change in custom field search behaviour impacting on performance https://issues.civicrm.org/jira/browse/CRM-17422 --- diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index 0dd5e95ae8..a4abacda18 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -360,8 +360,8 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { } $this->_formValues[$element] = array('IN' => $value); } - else { - $this->_formValues[$element] = array('LIKE' => "%$value%"); + elseif ((substr($formValues[$key], 0, 1) == '%') || (substr($formValues[$key], -1, 1) == '%')) { + $this->_formValues[$element] = array('LIKE' => $value); } } } diff --git a/CRM/Core/BAO/CustomValue.php b/CRM/Core/BAO/CustomValue.php index 3d34883fbe..557e4ab3a0 100644 --- a/CRM/Core/BAO/CustomValue.php +++ b/CRM/Core/BAO/CustomValue.php @@ -189,11 +189,11 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { elseif (($htmlType == 'TextArea' || ($htmlType == 'Text' && $dataType == 'String') ) && - !((substr($formValues[$key], 0, 1) == '%') || + ((substr($formValues[$key], 0, 1) == '%') || (substr($formValues[$key], -1, 1) == '%') ) ) { - $formValues[$key] = array('LIKE' => '%' . $formValues[$key] . '%'); + $formValues[$key] = array('LIKE' => $formValues[$key]); } } }