From 66ddb273a19efccb05ff87530d053d4b6a61edcc Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 29 Apr 2018 15:21:55 +1000 Subject: [PATCH] Dev/Core#90 Apply disabling Full Group By to reports --- CRM/Report/Form.php | 10 ++++++++++ CRM/Report/Form/Contribute/Lybunt.php | 1 + CRM/Report/Form/Contribute/SoftCredit.php | 2 +- CRM/Report/Form/Mailing/Opened.php | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 5e9273a84e..7d8454fea4 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -487,6 +487,12 @@ class CRM_Report_Form extends CRM_Core_Form { */ protected $sqlArray; + + /** + * Can this report use the sql mode ONLY_FULL_GROUP_BY. + * @var bool + */ + public $optimisedForOnlyFullGroupBy = TRUE; /** * Class constructor. */ @@ -2952,7 +2958,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @param array $rows */ public function buildRows($sql, &$rows) { + if (!$this->optimisedForOnlyFullGroupBy) { + CRM_Core_DAO::disableFullGroupByMode(); + } $dao = CRM_Core_DAO::executeQuery($sql); + CRM_Core_DAO::enableFullGroupByMode(); if (!is_array($rows)) { $rows = array(); } diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 42b8d6e41e..0fb7f093a5 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -77,6 +77,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { * Class constructor. */ public function __construct() { + $this->optimisedForOnlyFullGroupBy = FALSE; $this->_rollup = 'WITH ROLLUP'; $this->_autoIncludeIndexedFieldsAsOrderBys = 1; $yearsInPast = 10; diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index fceb168b6d..4bb31c9704 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -68,7 +68,7 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { /** */ public function __construct() { - + $this->optimisedForOnlyFullGroupBy = FALSE; // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index 86391f2ed6..e893b75fc8 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -68,6 +68,7 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { * Class constructor. */ public function __construct() { + $this->optimisedForOnlyFullGroupBy = FALSE; $this->_columns = array(); $this->_columns['civicrm_contact'] = array( -- 2.25.1