CRM-17060 fix for post code groups with IN not working
authoreileenmcnaugton <eileen@fuzion.co.nz>
Fri, 21 Aug 2015 05:55:26 +0000 (17:55 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Fri, 21 Aug 2015 05:55:26 +0000 (17:55 +1200)
CRM/Contact/BAO/Query.php

index a785c2e5f65c2cadaab27c4818f471a69b974917..e291aadaaa1917c1127bc47f79a021611ff3f5c5 100644 (file)
@@ -3503,7 +3503,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;
@@ -5177,6 +5184,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);
         }