Dev/Core#90 Apply disabling Full Group By to reports
authorSeamus Lee <seamuslee001@gmail.com>
Sun, 29 Apr 2018 05:21:55 +0000 (15:21 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 29 Apr 2018 05:21:57 +0000 (15:21 +1000)
CRM/Report/Form.php
CRM/Report/Form/Contribute/Lybunt.php
CRM/Report/Form/Contribute/SoftCredit.php
CRM/Report/Form/Mailing/Opened.php

index 5e9273a84e8aa953f876e7b07b623b9fe78222b8..7d8454fea48d01ac00601eeade272c979e2d59a8 100644 (file)
@@ -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();
     }
index 42b8d6e41ee794c7c350afaae1dc8164c47348e1..0fb7f093a5d8ec4e0e09cb1981322d15687e3ad7 100644 (file)
@@ -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;
index fceb168b6d5ed933c529fb368c21f50f8e10f575..4bb31c9704bc4510ba0cff503f00a9a2d9ac0019 100644 (file)
@@ -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);
index 86391f2ed61a50003475d1884dcb89c58d6a7771..e893b75fc86adb05c710e6f314f830725e22658e 100644 (file)
@@ -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(