From: eileen Date: Tue, 15 Mar 2016 22:59:25 +0000 (+1300) Subject: CRM-18246 Lybunt group clause not being included in temp table due to order of operations X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2c0e8e6bd25f917f222ca7a10b10b6784d4a04e8;p=civicrm-core.git CRM-18246 Lybunt group clause not being included in temp table due to order of operations --- diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index b5703dcf01..3a3b2b92e9 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -414,7 +414,13 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { * @return string */ public function whereGroupClause($field, $value, $op) { - if (empty($this->contactTempTable)) { + if ($op == 'notin') { + // We do not have an optimisation for this scenario at this stage. Use + // parent. + return parent::whereGroupClause($field, $value, $op); + } + + if (empty($this->groupTempTable)) { $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; $group->find(); @@ -656,10 +662,13 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { * @return string */ public function buildQuery($applyLimit = TRUE) { + + // Calling where & select before FROM allows us to build temp tables to use in from. + $this->where(); $this->select(); $this->from(); $this->customDataFrom(empty($this->contactTempTable)); - $this->where(); + $this->groupBy(); $this->orderBy(); $this->getPermissionedFTQuery($this);