From: Matthew Wire Date: Thu, 23 Jan 2020 22:53:16 +0000 (+0000) Subject: If CiviContribute is not enabled don't crash when calling ContributionPage.getoptions... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=341a4d71ca9fdec7c2e71f83a8647a9b300f3748;p=civicrm-core.git If CiviContribute is not enabled don't crash when calling ContributionPage.getoptions or Event.getoptions --- diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index d74a952e9c..43cbb90546 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -828,10 +828,13 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm // Special logic for fields whose options depend on context or properties switch ($fieldName) { case 'financial_type_id': - // Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get - return CRM_Financial_BAO_FinancialType::getIncomeFinancialType(); - - break; + // @fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get + // @fixme - https://lab.civicrm.org/dev/core/issues/547 if CiviContribute not enabled this causes an invalid query + // because $relationTypeId is not set in CRM_Financial_BAO_FinancialType::getIncomeFinancialType() + if (array_key_exists('CiviContribute', CRM_Core_Component::getEnabledComponents())) { + return CRM_Financial_BAO_FinancialType::getIncomeFinancialType(); + } + return []; } return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index dabaa2d19b..e9e5acfc31 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -2348,10 +2348,13 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field // Special logic for fields whose options depend on context or properties switch ($fieldName) { case 'financial_type_id': - // Fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get - return CRM_Financial_BAO_FinancialType::getIncomeFinancialType(); - - break; + // @fixme - this is going to ignore context, better to get conditions, add params, and call PseudoConstant::get + // @fixme - https://lab.civicrm.org/dev/core/issues/547 if CiviContribute not enabled this causes an invalid query + // because $relationTypeId is not set in CRM_Financial_BAO_FinancialType::getIncomeFinancialType() + if (array_key_exists('CiviEvent', CRM_Core_Component::getEnabledComponents())) { + return CRM_Financial_BAO_FinancialType::getIncomeFinancialType(); + } + return []; } return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); }