Eileen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/351127 )
Change subject: Further removal of class_api3 call in favour of civicrm_api3
......................................................................
Further removal of class_api3 call in favour of civicrm_api3
class_api is causing test failures when the updated mysqli driver tries to free
memory
This replacement promotes the use of wmf_civicrm_get_option() as a cached
methodology
to retrieve an option for any field. There is actually caching at the api level
so the extra caching here is probably of marginal benefit, but I am replacing a
statically cached call.
Change-Id: I2b78783f87a5f352b85b3adce2dbd8f203682136
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
1 file changed, 21 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/27/351127/1
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index ef2b81f..eb08c4b 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -83,7 +83,7 @@
function civicrm_api_contribution_status($key = null)
{
- return civicrm_api_option_group('contribution_status', $key);
+ return wmf_civicrm_get_option('Contribution', 'contribution_status_id',
$key);
}
function civicrm_api_classapi()
@@ -3423,8 +3423,26 @@
* @throws \CiviCRM_API3_Exception
*/
function wmf_civicrm_get_options($entity, $field) {
- $options = civicrm_api3($entity, 'getoptions', array('field' => $field));
- return $options['values'];
+ if (!isset(\Civi::$statics['wmf_civicrm'][$entity][$field])) {
+ $options = civicrm_api3($entity, 'getoptions', array('field' => $field));
+ \Civi::$statics['wmf_civicrm'][$entity][$field] = $options['values'];
+ }
+ return \Civi::$statics['wmf_civicrm'][$entity][$field];
+}
+
+/**
+ * Get options for a field.
+ *
+ * @param string $entity
+ * @param string $field
+ * @param string $key
+ *
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ */
+function wmf_civicrm_get_option($entity, $field, $key) {
+ $options = wmf_civicrm_get_options($entity, $field);
+ return array_search($key, $options);
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/351127
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b78783f87a5f352b85b3adce2dbd8f203682136
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits