Merge pull request #6551 from eileenmcnaughton/CRM-17060
authorMonish Deb <monish.deb@webaccessglobal.com>
Fri, 21 Aug 2015 14:37:46 +0000 (20:07 +0530)
committerMonish Deb <monish.deb@webaccessglobal.com>
Fri, 21 Aug 2015 14:37:46 +0000 (20:07 +0530)
CRM-17060 fix for post code groups with IN not working

CRM/Contact/BAO/Query.php

index 2a778ef5629e9d5b4259200d629cbf055ff482f4..bd8f765f88fcb46e18cd2b000efb3afd07a4e742 100644 (file)
@@ -3486,7 +3486,14 @@ WHERE  $smartGroupClause
     }
     else {
       $field = 'civicrm_address.postal_code';
-      $val = CRM_Utils_Type::escape($value, 'String');
+      // Per CRM-17060 we might be looking at an 'IN' syntax so don't case arrays to string.
+      if (!is_array($value)) {
+        $val = CRM_Utils_Type::escape($value, 'String');
+      }
+      else {
+        // Do we need to escape values here? I would expect buildClause does.
+        $val = $value;
+      }
     }
 
     $this->_tables['civicrm_address'] = $this->_whereTables['civicrm_address'] = 1;
@@ -5160,6 +5167,7 @@ SELECT COUNT( conts.total_amount ) as cancel_count,
 
       case 'IN':
       case 'NOT IN':
+        // I feel like this would be escaped properly if passed through $queryString = CRM_Core_DAO::createSqlFilter.
         if (!empty($value) && is_array($value) && !array_key_exists($op, $value)) {
           $value = array($op => $value);
         }