Move wrangling payment header outside main row iteration
authoreileen <emcnaughton@wikimedia.org>
Mon, 12 Nov 2018 01:50:31 +0000 (14:50 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 15 Nov 2018 23:26:14 +0000 (12:26 +1300)
CRM/Export/BAO/Export.php

index 99ba90ee5a157ce7308062d0b7c1bfb56e4c1a5a..5699194a4ac5970da5c9e2d5fb1f57c9fb866f8b 100644 (file)
@@ -459,6 +459,16 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
 
     list($outputColumns, $headerRows, $sqlColumns, $metadata) = self::getExportStructureArrays($returnProperties, $processor);
 
+    // add payment headers if required
+    if ($addPaymentHeader && $processor->isExportPaymentFields()) {
+      // @todo rather than do this for every single row do it before the loop starts.
+      // where other header definitions take place.
+      $headerRows = array_merge($headerRows, $processor->getPaymentHeaders());
+      foreach (array_keys($processor->getPaymentHeaders()) as $paymentHdr) {
+        self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr);
+      }
+    }
+
     $limitReached = FALSE;
     while (!$limitReached) {
       $limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
@@ -523,16 +533,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
           }
         }
 
-        // add payment headers if required
-        if ($addPaymentHeader && $processor->isExportPaymentFields()) {
-          // @todo rather than do this for every single row do it before the loop starts.
-          // where other header definitions take place.
-          $headerRows = array_merge($headerRows, $processor->getPaymentHeaders());
-          foreach (array_keys($processor->getPaymentHeaders()) as $paymentHdr) {
-            self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr);
-          }
-        }
-
         if ($setHeader) {
           $exportTempTable = self::createTempTable($sqlColumns);
         }