From c995043caeb5a5e7175882fac77fa44c893575a2 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 20 Oct 2015 13:53:49 +0530 Subject: [PATCH] CRM-17422 fix - Change in custom field search behaviour impacting on performance https://issues.civicrm.org/jira/browse/CRM-17422 --- CRM/Contact/Form/Search/Advanced.php | 4 ++-- CRM/Core/BAO/CustomValue.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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]); } } } -- 2.25.1