From d02c030fccbbad3342d9a40821c1f2be6be58d0f Mon Sep 17 00:00:00 2001 From: monishdeb Date: Thu, 30 Jul 2015 15:28:27 +0530 Subject: [PATCH] CRM-16931 fix - Update Smart Group Counts throws a syntax error (AND instead of WHERE) https://issues.civicrm.org/jira/browse/CRM-16931 --- CRM/Contact/BAO/GroupContactCache.php | 3 +++ CRM/Contact/Form/Search/Custom/ContribSYBNT.php | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index a1cf6d594e..ba013e276d 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -482,6 +482,9 @@ WHERE id = %1 $customClass = CRM_Contact_BAO_SearchCustom::customClass($ssParams['customSearchID'], $savedSearchID); $searchSQL = $customClass->contactIDs(); $searchSQL = str_replace('ORDER BY contact_a.id ASC', '', $searchSQL); + if (!strstr($searchSQL, 'WHERE')) { + $searchSQL .= " WHERE ( 1 ) "; + } $idName = 'contact_id'; } else { diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index 8c5c9114ad..848742331b 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -167,18 +167,15 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc $from = $this->from(); + $select = $this->select(); if ($justIDs) { - $select = $this->select(); $select .= ', contact_a.id, display_name'; } else { - $select = $this->select(); $select = " DISTINCT contact_a.id as contact_id, contact_a.display_name as display_name, - $select -"; - + $select "; } $this->buildACLClause('contact_a'); $sql = " -- 2.25.1