From: Jamie McClelland Date: Tue, 26 May 2015 20:32:59 +0000 (-0400) Subject: CRM-16569 - avoid backtrace when adding contacts to group X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7f6464a099d2becc2fb90ddb68b90155109dc6fb;p=civicrm-core.git CRM-16569 - avoid backtrace when adding contacts to group This happens if you filter on target name with a contains or not contains. --- diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 938378981e..d3bbdfb13f 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -652,9 +652,13 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { CRM_Core_Error::fatal(ts('Current filter criteria didn\'t have any target contact to add to group')); } - $query = "{$this->_select} + $new_select = 'AS addtogroup_contact_id'; + $select = str_ireplace('AS civicrm_contact_contact_target_id', $new_select, $this->_select); + $new_having = ' addtogroup_contact_id'; + $having = str_ireplace(' civicrm_contact_contact_target_id', $new_having, $this->_having); + $query = "$select FROM civireport_activity_temp_target tar -GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}"; +GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $select = 'AS addtogroup_contact_id'; $query = str_ireplace('AS civicrm_contact_contact_target_id', $select, $query); $dao = CRM_Core_DAO::executeQuery($query);