From: unknown Date: Wed, 27 May 2015 13:36:06 +0000 (+0100) Subject: Proposed fix for searching similar multi select values CRM-16575 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=24f717cb0c7e75170ff627ab372c90543add0162;p=civicrm-core.git Proposed fix for searching similar multi select values CRM-16575 --- diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 512b7595c4..717c50fe37 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -400,9 +400,20 @@ SELECT label, value else { $val = CRM_Utils_Type::escape($strtolower(trim($value)), 'String'); - if ($wildcard) { - $val = $strtolower(CRM_Core_DAO::escapeString($val)); - $val = "%$val%"; + $specialHTMLType = array( + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + 'Multi-Select State/Province', + 'Multi-Select Country', + ); + + if (in_array($field['html_type'], $specialHTMLType)) { + $val = "[[:cntrl:]]".$val."[[:cntrl:]]"; + $op = 'RLIKE'; + + } elseif ($wildcard) { + $val = "[[:cntrl:]]%$val%[[:cntrl:]]"; $op = 'LIKE'; } diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index f8127d4cce..d99295aba2 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -1739,8 +1739,8 @@ class CRM_Report_Form extends CRM_Core_Form { if ($value !== NULL && count($value) > 0) { $sqlOP = $this->getSQLOperator($op); $clause - = "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) . - "[[:>:]]'"; + = "{$field['dbAlias']} REGEXP '[[:cntrl:]]" . implode('|', $value) . + "[[:cntrl:]]'"; } break; @@ -1749,8 +1749,8 @@ class CRM_Report_Form extends CRM_Core_Form { if ($value !== NULL && count($value) > 0) { $sqlOP = $this->getSQLOperator($op); $clause - = "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) . - "[[:>:]]' OR {$field['dbAlias']} IS NULL )"; + = "( {$field['dbAlias']} NOT REGEXP '[[:cntrl:]]" . implode('|', $value) . + "[[:cntrl:]]' OR {$field['dbAlias']} IS NULL )"; } break;