diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 5e9273a84e8a..7d8454fea48d 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 @@ public function unselectedSectionColumns() { * @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 42b8d6e41ee7..0fb7f093a5d8 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 fceb168b6d5e..4bb31c9704bc 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 86391f2ed61a..e893b75fc86a 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(