From 639e74e52e883d80e127512351d2c5e51a7d0aad Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 19 Nov 2018 00:22:44 +0530 Subject: [PATCH] Query building shouldn't be iterated --- CRM/Batch/BAO/Batch.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 924bb55138..3424c78657 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -745,19 +745,18 @@ LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id $values['contribution_date_low'] = $date['from']; $values['contribution_date_high'] = $date['to']; } - $searchParams = CRM_Contact_BAO_Query::convertFormValues($values); - // @todo the use of defaultReturnProperties means the search will be inefficient - // as slow-unneeded properties are included. - $query = new CRM_Contact_BAO_Query($searchParams, - CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE, - FALSE - ), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE - ); - if ($field == 'contribution_date_high' || $field == 'contribution_date_low') { - $query->dateQueryBuilder($params[$field], 'civicrm_contribution', 'contribution_date', 'receive_date', 'Contribution Date'); - } } } + + $searchParams = CRM_Contact_BAO_Query::convertFormValues($values); + // @todo the use of defaultReturnProperties means the search will be inefficient + // as slow-unneeded properties are included. + $query = new CRM_Contact_BAO_Query($searchParams, + CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE, + FALSE + ), NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE + ); + if (!empty($query->_where[0])) { $where = implode(' AND ', $query->_where[0]) . " AND civicrm_entity_batch.batch_id IS NULL "; -- 2.25.1