Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/243120
Change subject: Cleanup: Drupal 7 hook_update_N signature ...................................................................... Cleanup: Drupal 7 hook_update_N signature As documented here, https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_update_N/7 TODO: * Do this in the other .install files. * Civi class-based API is deprecated. Change-Id: Id25f2ab0c8e008d7a338d417c56222498610a186 --- M sites/all/modules/wmf_civicrm/wmf_civicrm.install 1 file changed, 58 insertions(+), 87 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/20/243120/1 diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install b/sites/all/modules/wmf_civicrm/wmf_civicrm.install index 75c8c7b..96319c6 100644 --- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install +++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install @@ -59,7 +59,7 @@ 'name' => 'Gift_Data', ) ); if ( !$success || !count( $api->values ) ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $custom_group_id = $api->values[0]->id; @@ -69,7 +69,7 @@ 'name' => $field_name, ) ); if ( !$success || !count( $api->values ) ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $custom_field_id = $api->values[0]->id; @@ -85,7 +85,7 @@ 'title' => $field_name, ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } $option_group_id = $api->values[0]->id; @@ -102,7 +102,7 @@ 'value' => $value, ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } } @@ -119,7 +119,7 @@ 'is_searchable' => 1, ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } @@ -163,8 +163,6 @@ wmf_civicrm_bootstrap_civi(); wmf_civicrm_create_financial_types($contribution_types); wmf_civicrm_create_option_values( 'payment_instrument', $payment_instruments ); - - return array(); } /** @@ -187,7 +185,7 @@ 'is_active' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $result = $api->values(); } @@ -209,10 +207,8 @@ 'time_format' => 2, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return array(); } /** @@ -225,7 +221,7 @@ 'name' => 'contribution_extra', )); if (!$success) { - throw new Exception($api->errorMsg()); + throw new DrupalUpdateException($api->errorMsg()); } $values = $api->values(); $custom_group = array_pop($values); @@ -243,10 +239,8 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return array(); } function wmf_civicrm_update_7003() @@ -267,7 +261,7 @@ 'name' => 'contribution_extra', )); if (!$success) { - throw new Exception($api->errorMsg()); + throw new DrupalUpdateException($api->errorMsg()); } $values = $api->values(); $custom_group = array_pop($values); @@ -284,10 +278,8 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return array(); } /** @@ -295,14 +287,12 @@ */ function wmf_civicrm_update_7005() { - $ret = array(); - $api = wmf_civicrm_bootstrap_civi(); $success = $api->CustomGroup->get(array( 'name' => 'contribution_extra', )); if (!$success) { - throw new Exception($api->errorMsg()); + throw new DrupalUpdateException($api->errorMsg()); } $values = $api->values(); $custom_group = array_pop($values); @@ -319,7 +309,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -334,7 +324,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -349,7 +339,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -364,7 +354,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -382,7 +372,7 @@ 'time_format' => 2, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -398,7 +388,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -413,7 +403,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -429,7 +419,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -444,7 +434,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -462,7 +452,7 @@ 'time_format' => 2, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -478,7 +468,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -493,7 +483,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -508,7 +498,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -523,10 +513,8 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return $ret; } /** @@ -534,8 +522,6 @@ */ function wmf_civicrm_update_7006() { - $ret = array(); - wmf_civicrm_create_option_values('contribution_status', array( 'Settled', 'Paid', @@ -548,7 +534,7 @@ 'name' => 'contribution_extra', )); if (!$success) { - throw new Exception($api->errorMsg()); + throw new DrupalUpdateException($api->errorMsg()); } $custom_group = $api->values[0]; $success = $api->CustomField->get(array( @@ -561,11 +547,9 @@ 'id' => $field->id, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } - - return $ret; } /** @@ -585,7 +569,7 @@ 'description' => 'Review', )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } @@ -652,14 +636,13 @@ */ function wmf_civicrm_update_7012() { - $ret = array(); $api = wmf_civicrm_bootstrap_civi(); $success = $api->CustomGroup->get(array( 'name' => 'contribution_extra', )); if (!$success) { - throw new Exception($api->errorMsg()); + throw new DrupalUpdateException($api->errorMsg()); } $values = $api->values(); $custom_group = array_pop($values); @@ -676,7 +659,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -691,7 +674,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -706,7 +689,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -721,7 +704,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -736,7 +719,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -754,10 +737,8 @@ 'time_format' => 2, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return implode("\n", $ret); } /** @@ -784,10 +765,8 @@ 'is_view' => 0, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } - - return $ret; } /** @@ -815,7 +794,7 @@ 'is_view' => 0, )); if (!$success) { - $ret[] = $api->errorMsg(); + throw new DrupalUpdateException( $api->errorMsg() ); } $dbs = wmf_civicrm_get_dbs(); @@ -829,8 +808,6 @@ wmf_contribution_extra.entity_id = civicrm_contribution.id AND thankyou_date = '1970-01-01 00:00:00' " ); - - return $ret; } /** @@ -869,7 +846,7 @@ 'used_for' => 'civicrm_contribution' )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } } @@ -894,7 +871,7 @@ 'used_for' => 'civicrm_contact' )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } } @@ -961,7 +938,7 @@ 'used_for' => 'civicrm_contribution' )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } } @@ -982,7 +959,7 @@ 'is_active' => 1, )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } $custom_group_id = $api->values[0]->id; @@ -1000,7 +977,7 @@ 'is_searchable' => 1, )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1016,7 +993,7 @@ 'is_searchable' => 1, )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1032,7 +1009,7 @@ 'is_searchable' => 1, )); if (!$success) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } // TODO: define option groups in another migration if necessary @@ -1059,7 +1036,7 @@ 'is_active' => 1, )); if (!$success) { - throw new Exception('Could not create custom group'); + throw new DrupalUpdateException('Could not create custom group'); } $values = $api->values(); $custom_group = array_pop($values); @@ -1076,7 +1053,7 @@ 'is_searchable' => 1, )); if (!$success) { - throw new Exception('Failed to create custom field.'); + throw new DrupalUpdateException('Failed to create custom field.'); } } @@ -1090,7 +1067,7 @@ )); $result = $api->values(); if (!$result) { - throw new Exception('Could not find custom group wmf_donor. Please run update 7023 first.'); + throw new DrupalUpdateException('Could not find custom group wmf_donor. Please run update 7023 first.'); } $custom_group = array_pop($result); @@ -1110,7 +1087,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } $success = $api->CustomField->create(array( @@ -1128,7 +1105,7 @@ 'time_format' => 2, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1143,7 +1120,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1159,7 +1136,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1175,7 +1152,7 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } $success = $api->CustomField->create(array( @@ -1191,9 +1168,8 @@ 'is_view' => 1, )); if (!$success) { - $ret[] = array( 'success' => false, 'query' => $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } - return $ret; } /** @@ -1212,8 +1188,6 @@ function wmf_civicrm_update_7026() { wmf_civicrm_create_option_values( 'payment_instrument', array( 'Alipay' ) ); - - return array(); } /** @@ -1227,7 +1201,7 @@ )); $result = $api->values(); if (!$result) { - throw new Exception('Could not find custom group wmf_donor. Please run update 7023 first.'); + throw new DrupalUpdateException('Could not find custom group wmf_donor. Please run update 7023 first.'); } $custom_group = array_pop($result); @@ -1300,7 +1274,7 @@ 'is_active' => 1, ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } $custom_group_id = $api->id; @@ -1359,7 +1333,7 @@ 'is_active' => 1, ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } $custom_group = $api->values[0]; @@ -1374,7 +1348,7 @@ 'name' => 'Description_of_Stock', ) ); if ( !$success ) { - throw new Exception( $api->errorMsg() ); + throw new DrupalUpdateException( $api->errorMsg() ); } } @@ -1420,7 +1394,6 @@ function wmf_civicrm_update_7033() { wmf_civicrm_bootstrap_civi(); wmf_civicrm_create_option_values( 'payment_instrument', array('Square Cash') ); - return array(); } /** @@ -1429,7 +1402,6 @@ function wmf_civicrm_update_7034() { wmf_civicrm_bootstrap_civi(); wmf_civicrm_create_option_values( 'payment_instrument', array('Trilogy') ); - return array(); } @@ -1446,5 +1418,4 @@ wmf_civicrm_create_option_values_detailed('tag_used_for', array( 'Contributions' => array('value' => 'civicrm_contribution'), )); - return array(); } -- To view, visit https://gerrit.wikimedia.org/r/243120 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id25f2ab0c8e008d7a338d417c56222498610a186 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: civi-4.6.9 Gerrit-Owner: Awight <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
