jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/351128 )

Change subject: Further removal of class_api3 call in favour of civicrm_api3.
......................................................................


Further removal of class_api3 call in favour of civicrm_api3.

In this case fix the initial option value creation routine

This should only really affect dev instances as this is all 'done' on live.

Change-Id: If4e0c50705c4ea8da9db0d6eeb2f3daf88ea96f0
---
M sites/all/modules/wmf_civicrm/bootstrap.inc
1 file changed, 10 insertions(+), 13 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/wmf_civicrm/bootstrap.inc 
b/sites/all/modules/wmf_civicrm/bootstrap.inc
index 4bba64b..409d255 100644
--- a/sites/all/modules/wmf_civicrm/bootstrap.inc
+++ b/sites/all/modules/wmf_civicrm/bootstrap.inc
@@ -93,33 +93,30 @@
  */
 function wmf_civicrm_create_option_values_detailed($group_name, $values)
 {
-    $api = wmf_civicrm_bootstrap_civi();
-
-    $api->OptionGroup->Get(array(
+    civicrm_initialize();
+    $optionGroup = civicrm_api3('OptionGroup', 'getsingle', array(
       'name' => $group_name,
     ));
-    $result = $api->values();
-    $option_group = array_pop($result);
+
     foreach ($values as $key => $value)
     {
         $params = array_merge(array(
-          'option_group_id' => $option_group->id,
+          'option_group_id' => $optionGroup['id'],
           'name' => $key,
           'label' => $key,
           'is_active' => 1,
         ), $value);
 
-        $api->OptionValue->Get(array(
-          'option_group_id' => $option_group->id,
+        $result = civicrm_api3('OptionValue', 'get', array(
+          'option_group_id' => $optionGroup['id'],
           'name' => $params['name'],
         ));
-
-        $result = $api->values();
-        if (empty($result))
-        {
-            $api->OptionValue->Create($params);
+        if ($result['count'] === 0) {
+          civicrm_api3('OptionValue', 'create', $params);
+          wmf_civicrm_flush_cached_options();
         }
     }
+
 }
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/351128
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If4e0c50705c4ea8da9db0d6eeb2f3daf88ea96f0
Gerrit-PatchSet: 13
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to