Commit 43767da2 authored by eileen's avatar eileen

Move order by to query generator

parent 7628764a
......@@ -158,22 +158,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
// This perhaps only needs calling when $mergeSameHousehold == 1
self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable);
if ($order) {
// always add contact_a.id to the ORDER clause
// so the order is deterministic
//CRM-15301
if (strpos('contact_a.id', $order) === FALSE) {
$order .= ", contact_a.id";
}
list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (!empty($processor->getReturnProperties()[$field])) {
//CRM-15301
$queryString .= " ORDER BY $order";
}
}
$addPaymentHeader = FALSE;
list($outputColumns, $metadata) = self::getExportStructureArrays($processor);
......
......@@ -743,7 +743,23 @@ class CRM_Export_BAO_ExportProcessor {
}
$groupBy = $this->getGroupBy($query);
return [$query, "$select $from $where $having $groupBy"];
$queryString = "$select $from $where $having $groupBy";
if ($order) {
// always add contact_a.id to the ORDER clause
// so the order is deterministic
//CRM-15301
if (strpos('contact_a.id', $order) === FALSE) {
$order .= ", contact_a.id";
}
list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (!empty($this->getReturnProperties()[$field])) {
//CRM-15301
$queryString .= " ORDER BY $order";
}
}
return [$query, $queryString];
}
/**
......@@ -1677,6 +1693,7 @@ class CRM_Export_BAO_ExportProcessor {
}
return $returnProperties;
}
/**
* @param object $query
* CRM_Contact_BAO_Query
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment