CRM-16961 fix for search for cust data with parentheses
authoreileenmcnaugton <eileen@fuzion.co.nz>
Wed, 5 Aug 2015 23:51:31 +0000 (11:51 +1200)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 6 Aug 2015 06:58:26 +0000 (12:28 +0530)
Conflicts:
CRM/Core/BAO/CustomQuery.php

----------------------------------------
* CRM-16961: 4.6.5 search regression on custom fields where option values have brackets
  https://issues.civicrm.org/jira/browse/CRM-16961

CRM/Core/BAO/CustomQuery.php

index 747e07a8e14cefaf7aebf1c6655a442107e3f88d..34f2df43bd56845b4b31238e16ecd40c121b0304 100644 (file)
@@ -423,14 +423,15 @@ SELECT label, value
 
               // CRM-14563,CRM-16575 : Special handling of multi-select custom fields
               if ($isSerialized && !empty($value)) {
-                $specialChar = '[' . CRM_Core_DAO::VALUE_SEPARATOR . ']*';
                 if (strstr($op, 'IN')) {
-                  $value = str_replace(",", "$specialChar|$specialChar", $value);
+                  $value = str_replace(",", "[[:cntrl:]]*|[[:cntrl:]]*", $value);
+                  $value = str_replace('(', '[[.left-parenthesis.]]', $value);
+                  $value = str_replace(')', '[[.right-parenthesis.]]', $value);
                 }
                 $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
-                $value = "$specialChar$value$specialChar";
+                $value = "[[:cntrl:]]*" . $value . "[[:cntrl:]]*";
                 if (!$wildcard) {
-                  $value = str_replace("$specialChar|", '', $value);
+                  $value = str_replace("[[:cntrl:]]*|", '', $value);
                 }
               }