From 72c506e9e7d3d8e8ac52225a6bbe036cecedf942 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 6 Jun 2019 13:08:41 +1200 Subject: [PATCH] Minor code cleanup on string concatenation Just slightly simplifies the building of the whereClause --- CRM/Export/BAO/Export.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index eb1e98a5c8..676c9ca335 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -349,32 +349,26 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c ); } + $whereClauses = ['trash_clause' => "contact_a.is_deleted != 1"]; if (!$selectAll && $componentTable) { $from .= " INNER JOIN $componentTable ctTable ON ctTable.contact_id = contact_a.id "; } elseif ($componentClause) { - if (empty($where)) { - $where = "WHERE $componentClause"; - } - else { - $where .= " AND $componentClause"; - } + $whereClauses[] = $componentClause; } // CRM-13982 - check if is deleted - $excludeTrashed = TRUE; foreach ($params as $value) { if ($value[0] == 'contact_is_deleted') { - $excludeTrashed = FALSE; + unset($whereClauses['trash_clause']); } } - $trashClause = $excludeTrashed ? "contact_a.is_deleted != 1" : "( 1 )"; if (empty($where)) { - $where = "WHERE $trashClause"; + $where = "WHERE " . implode(' AND ', $whereClauses); } else { - $where .= " AND $trashClause"; + $where .= " AND " . implode(' AND ', $whereClauses); } $queryString = "$select $from $where $having"; -- 2.25.1