);
}
+ /**
+ * Upgrade function.
+ *
+ * @param string $rev
+ */
+ public function upgrade_5_41_beta1($rev) {
+ $this->addTask('Ensure non-English installs have a default financial type for the membership price set.',
+ 'ensureDefaultMembershipFinancialType');
+ }
+
+ public static function ensureDefaultMembershipFinancialType(): bool {
+ $membershipPriceSet = CRM_Core_DAO::executeQuery(
+ 'SELECT id, financial_type_id FROM civicrm_price_set WHERE name = "default_membership_type_amount"'
+ );
+ $membershipPriceSet->fetch();
+ if (!is_numeric($membershipPriceSet->financial_type_id)) {
+ $membershipFinancialTypeID = CRM_Core_DAO::singleValueQuery('
+ SELECT id FROM civicrm_financial_type
+ WHERE name = "Member Dues"
+ OR name = %1', [1 => [ts('Member Dues'), 'String']]
+ );
+ if (!$membershipFinancialTypeID) {
+ // This should be unreachable - but something is better than nothing
+ // if we get to this point & 2 will be correct on 99.9% of installs.
+ $membershipFinancialTypeID = 2;
+ }
+ CRM_Core_DAO::executeQuery("
+ UPDATE civicrm_price_set
+ SET financial_type_id = $membershipFinancialTypeID
+ WHERE name = 'default_membership_type_amount'"
+ );
+
+ }
+ return TRUE;
+ }
+
/**
* Install CustomSearches extension.
*
-- CRM-9714
-SELECT @financial_type_id := max(id) FROM `civicrm_financial_type` WHERE `name` = 'Member Dues';
INSERT INTO `civicrm_price_set` ( `name`, `title`, `is_active`, `extends`, `is_quick_config`, `financial_type_id`, `is_reserved` )
VALUES ( 'default_contribution_amount', 'Contribution Amount', '1', '2', '1', NULL,1),
-( 'default_membership_type_amount', 'Membership Amount', '1', '3', '1', @financial_type_id,1);
+( 'default_membership_type_amount', 'Membership Amount', '1', '3', '1', @financial_type_id_md,1);
SELECT @setID := max(id) FROM civicrm_price_set WHERE name = 'default_contribution_amount' AND extends = 2 AND is_quick_config = 1 ;