From 8489e9e09a39d22ac7e8404a0bca8719f0dfed1f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 13 Jan 2022 13:11:24 +1300 Subject: [PATCH] Remove handling for impossible array CRM_Financial_BAO_FinancialType::buildPermissionedClause is only called from one place outside of tests. That place passes in this->_whereClause which is the result of calling this->whereClause() a few lines earlier. As that function always returns a string we know that it cannot be an array & can remove the handling --- CRM/Contact/BAO/Query.php | 2 +- CRM/Financial/BAO/FinancialType.php | 37 ++++++++++------------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 608e257d9b..a487b37af4 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2038,7 +2038,7 @@ class CRM_Contact_BAO_Query { * @return string * @throws \CRM_Core_Exception */ - public function whereClause($isForcePrimaryEmailOnly = NULL) { + public function whereClause($isForcePrimaryEmailOnly = NULL): string { $this->_where[0] = []; $this->_qill[0] = []; diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 5ac198e989..d5e8618961 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -356,33 +356,22 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im if (!self::isACLFinancialTypeStatus()) { return FALSE; } - if (is_array($whereClauses)) { + if ($component == 'contribution') { $types = self::getAllEnabledAvailableFinancialTypes(); - if (empty($types)) { - $whereClauses[] = ' ' . $alias . '.financial_type_id IN (0)'; - } - else { - $whereClauses[] = ' ' . $alias . '.financial_type_id IN (' . implode(',', array_keys($types)) . ')'; - } + $column = "financial_type_id"; } - else { - if ($component == 'contribution') { - $types = self::getAllEnabledAvailableFinancialTypes(); - $column = "financial_type_id"; - } - if ($component == 'membership') { - self::getAvailableMembershipTypes($types, CRM_Core_Action::VIEW); - $column = "membership_type_id"; - } - if (!empty($whereClauses)) { - $whereClauses .= ' AND '; - } - if (empty($types)) { - $whereClauses .= " civicrm_{$component}.{$column} IN (0)"; - return; - } - $whereClauses .= " civicrm_{$component}.{$column} IN (" . implode(',', array_keys($types)) . ")"; + if ($component == 'membership') { + self::getAvailableMembershipTypes($types, CRM_Core_Action::VIEW); + $column = "membership_type_id"; + } + if (!empty($whereClauses)) { + $whereClauses .= ' AND '; + } + if (empty($types)) { + $whereClauses .= " civicrm_{$component}.{$column} IN (0)"; + return; } + $whereClauses .= " civicrm_{$component}.{$column} IN (" . implode(',', array_keys($types)) . ")"; } /** -- 2.25.1