Eileen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/242360
Change subject: Civi46: fix another call to ContributionType
......................................................................
Civi46: fix another call to ContributionType
This bit of patchwork seems to have gotten lost in the process of patching the
wrong branch
BUG: T99836
Change-Id: I7e5f1866818a2013de65fe6962d2e5a7fb9de601
---
M sites/all/modules/wmf_civicrm/bootstrap.inc
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
2 files changed, 8 insertions(+), 21 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/60/242360/1
diff --git a/sites/all/modules/wmf_civicrm/bootstrap.inc
b/sites/all/modules/wmf_civicrm/bootstrap.inc
index 018ae90..14ebf15 100644
--- a/sites/all/modules/wmf_civicrm/bootstrap.inc
+++ b/sites/all/modules/wmf_civicrm/bootstrap.inc
@@ -34,6 +34,9 @@
*
* @param array $financial_types
*
+ * @return array
+ * Financial types in th DB.
+ *
* @throws \CiviCRM_API3_Exception
*/
function wmf_civicrm_create_financial_types($financial_types)
@@ -44,13 +47,15 @@
$missingTypes = array_diff($financial_types,
$existingFinancialTypes['values']);
foreach ($missingTypes as $type)
{
- civicrm_api3('FinancialType', 'create', array(
+ $result = civicrm_api3('FinancialType', 'create', array(
'is_active' => 1,
'is_deductible' => 1,
'accounting_code' => strtoupper($type),
'name' => $type,
));
+ $existingFinancialTypes[$result['id']] = $type;
}
+ return $existingFinancialTypes;
}
/**
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index 1794fd5..bc3f57a 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -1341,28 +1341,10 @@
* Add more custom fields that already exist on production
*/
function wmf_civicrm_update_7031() {
- $warnings = array();
$api = wmf_civicrm_bootstrap_civi();
-
- // No API available yet.
- $existingTypes = array_flip(
CRM_Contribute_PseudoConstant::contributionType() );
- if ( array_key_exists( 'Stock', $existingTypes ) ) {
- $stockContributionTypeId = $existingTypes['Stock'];
- } else {
- $params = array(
- 'accounting_code' => 'STOCK',
- 'is_active' => 1,
- 'is_deductible' => 1,
- 'name' => 'Stock',
- );
- $ids = array();
- $stockContributionType = CRM_Contribute_BAO_ContributionType::add(
$params, $ids );
- if ( is_a( $stockContributionType, 'CRM_Core_Error' ) ) {
- throw new Exception( $stockContributionType->getMessages() );
- }
- $stockContributionTypeId = $stockContributionType->id;
- }
+ $financialTypes = wmf_civicrm_create_financial_types(array('Stock'));
+ $stockContributionTypeId = array_search('Stock', $financialTypes);
$success = $api->CustomGroup->get(array(
'name' => 'Stock_Information',
--
To view, visit https://gerrit.wikimedia.org/r/242360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7e5f1866818a2013de65fe6962d2e5a7fb9de601
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: civi-4.6.9-deploy
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits