CRM-15750 - backporting fix to 4.5
authorDave Greenberg <dave@civicrm.org>
Wed, 4 Feb 2015 22:57:19 +0000 (14:57 -0800)
committerDave Greenberg <dave@civicrm.org>
Wed, 4 Feb 2015 22:57:19 +0000 (14:57 -0800)
----------------------------------------
* CRM-15750: advanced search using relationship and smart group produces backtrace
  https://issues.civicrm.org/jira/browse/CRM-15750

CRM/Contact/BAO/Query.php

index 1620bb6ca12322a30e1a6df328759cdc2b5f1c96..79d9e99d1912f0ee07d994f21dd6e3f161df9a60 100644 (file)
@@ -2888,12 +2888,12 @@ WHERE  id IN ( $groupIDs )
       $groupIDsFiltered = implode(',', $groupsFiltered);
 
       if ($tableAlias == NULL) {
-        $tableAlias = "civicrm_group_contact_cache_{$groupIDsFiltered}";
+        $tableAlias = "`civicrm_group_contact_cache_{$groupIDsFiltered}`";
       }
 
-      $this->_tables["`{$tableAlias}`"] = $this->_whereTables["`{$tableAlias}`"] = " LEFT JOIN civicrm_group_contact_cache `{$tableAlias}` ON {$joinTable}.id = `{$tableAlias}`.contact_id ";
+      $this->_tables[$tableAlias] = $this->_whereTables[$tableAlias] = " LEFT JOIN civicrm_group_contact_cache {$tableAlias} ON {$joinTable}.id = {$tableAlias}.contact_id ";
 
-      return "`{$tableAlias}`.group_id IN (" . $groupIDsFiltered . ")";
+      return "{$tableAlias}.group_id IN (" . $groupIDsFiltered . ")";
     }
 
     return NULL;