dev/core#651 Fix group by on export soft credits (possible recent regression, clearly...
authoreileen <emcnaughton@wikimedia.org>
Tue, 5 Feb 2019 06:04:21 +0000 (19:04 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 5 Feb 2019 20:00:33 +0000 (09:00 +1300)
As pointed out by the reporter the group by is being calculated as if it were a string but it's an array, this fixes.

This code has been touched recently so it might be a recent regression. 5.10 is the first release in a long time where
export is working in some mysql / output configs after a big refactor to get rid of wide temp tables

CRM/Export/BAO/Export.php

index cc7a41749eb52d8f1cc5acc30934ab86fa08b735..5ef3763257e7938fb808a6738bdd5dfd5932e3b8 100644 (file)
@@ -124,7 +124,7 @@ class CRM_Export_BAO_Export {
    *   Group By Clause
    */
   public static function getGroupBy($processor, $returnProperties, $query) {
-    $groupBy = '';
+    $groupBy = NULL;
     $exportMode = $processor->getExportMode();
     $queryMode = $processor->getQueryMode();
     if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) ||
@@ -140,7 +140,7 @@ class CRM_Export_BAO_Export {
         $groupBy = 'civicrm_contribution.id';
         if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
           // especial group by  when soft credit columns are included
-          $groupBy = array('contribution_search_scredit_combined.id', 'contribution_search_scredit_combined.scredit_id');
+          $groupBy = ['contribution_search_scredit_combined.id', 'contribution_search_scredit_combined.scredit_id'];
         }
         break;
 
@@ -157,7 +157,7 @@ class CRM_Export_BAO_Export {
       $groupBy = "civicrm_activity.id ";
     }
 
-    return $groupBy ? ' GROUP BY ' . $groupBy : '';
+    return $groupBy ? ' GROUP BY ' . implode(', ', (array) $groupBy) : '';
   }
 
   /**