fix bracket values in api and search builder
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 12 Jul 2016 11:33:03 +0000 (17:03 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 12 Jul 2016 11:33:03 +0000 (17:03 +0530)
CRM/Core/BAO/CustomQuery.php

index 51f06e319f1cb7f03c376e4db24cb8b6e2218666..00e3edf73392ca7a4d255dcd3c9d8de65d597c95 100644 (file)
@@ -339,6 +339,8 @@ SELECT f.id, f.label, f.data_type,
                 else {
                   $value = CRM_Utils_Type::escape($value, 'Integer');
                 }
+                $value = str_replace(array('[', ']', ','), array('\[', '\]', '[:comma:]'), $value);
+                $value = str_replace('|', '[:separator:]', $value);
               }
               elseif ($isSerialized) {
                 if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
@@ -357,10 +359,9 @@ SELECT f.id, f.label, f.data_type,
               // CRM-14563,CRM-16575 : Special handling of multi-select custom fields
               if ($isSerialized && !CRM_Utils_System::isNull($value) && !strstr($op, 'NULL') && !strstr($op, 'LIKE')) {
                 $sp = CRM_Core_DAO::VALUE_SEPARATOR;
-                if (strstr($op, 'IN')) {
-                  $value = str_replace(",", "$sp|$sp", $value);
-                  $value = str_replace(array('[:comma:]', '(', ')'), array(',', '[[.left-parenthesis.]]', '[[.right-parenthesis.]]'), $value);
-                }
+                $value = str_replace(",", "$sp|$sp", $value);
+                $value = str_replace(array('[:comma:]', '(', ')'), array(',', '[[.left-parenthesis.]]', '[[.right-parenthesis.]]'), $value);
+
                 $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
                 $value = $sp . $value . $sp;
                 if (!$wildcard) {