dev/core#2246 Fix failure to filter exports
authoreileen <emcnaughton@wikimedia.org>
Fri, 11 Dec 2020 05:04:25 +0000 (18:04 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 11 Dec 2020 05:04:25 +0000 (18:04 +1300)
This fixes regression caused by us more consistently setting componentTable.

The short version here is that the presence of a componentClause should take precedences
over the inner join intended as a blunt, and maybe unnecessary, measure to
limit the export to the entity in question

CRM/Export/BAO/ExportProcessor.php

index ab63f36eea3e55e7abeccc6f1361403739e4adfd..11e26f65eda3dfe258b9f87467e45f504f0a6e6e 100644 (file)
@@ -797,12 +797,12 @@ class CRM_Export_BAO_ExportProcessor {
     list($select, $from, $where, $having) = $query->query();
     $this->setQueryFields($query->_fields);
     $whereClauses = ['trash_clause' => "contact_a.is_deleted != 1"];
-    if ($this->getRequestedFields() && $this->getComponentTable() &&  $this->getComponentTable() !== 'civicrm_contact') {
-      $from .= " INNER JOIN " . $this->getComponentTable() . " ctTable ON ctTable.contact_id = contact_a.id ";
-    }
-    elseif ($this->getComponentClause()) {
+    if ($this->getComponentClause()) {
       $whereClauses[] = $this->getComponentClause();
     }
+    elseif ($this->getRequestedFields() && $this->getComponentTable() &&  $this->getComponentTable() !== 'civicrm_contact') {
+      $from .= " INNER JOIN " . $this->getComponentTable() . " ctTable ON ctTable.contact_id = contact_a.id ";
+    }
 
     // CRM-13982 - check if is deleted
     foreach ($params as $value) {