Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/149777
Change subject: Consolidate source data assignment ...................................................................... Consolidate source data assignment Change-Id: I39503ee4d80348c782a922dff2cc2c031ad4a603 --- M sites/all/modules/globalcollect_audit/globalcollect_audit.module M sites/all/modules/offline2civicrm/ChecksFile.php M sites/all/modules/recurring_globalcollect/recurring_globalcollect.module M sites/all/modules/wmf_civicrm/wmf_civicrm.module M sites/all/modules/wmf_common/wmf_common.module 5 files changed, 18 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/77/149777/1 diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.module b/sites/all/modules/globalcollect_audit/globalcollect_audit.module index aa830ae..fcd3eec 100644 --- a/sites/all/modules/globalcollect_audit/globalcollect_audit.module +++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.module @@ -1994,14 +1994,8 @@ throw new Exception( "What kind of a queue is this??: {$queueId}" ); } - $headers = array( - 'source_name' => "GlobalCollect WR1 Auditor", - 'source_type' => 'audit', - 'source_host' => gethostname(), - 'source_run_id' => getmypid(), - 'source_version' => wmf_common_get_my_revision(), - 'source_enqueued_at' => time(), - ); + $headers = array(); + wmf_common_set_message_source( $headers, 'audit', 'GlobalCollect WR1 Auditor' ); return $q->enqueue( json_encode( $body ), $headers, $queuePath ); } diff --git a/sites/all/modules/offline2civicrm/ChecksFile.php b/sites/all/modules/offline2civicrm/ChecksFile.php index a4a110e..29eefd2 100644 --- a/sites/all/modules/offline2civicrm/ChecksFile.php +++ b/sites/all/modules/offline2civicrm/ChecksFile.php @@ -130,7 +130,7 @@ throw new WmfException( 'CIVI_REQ_FIELD', t( "Missing required fields @keys during check import", array( "@keys" => implode( ", ", $failed ) ) ) ); } - $this->setSourceData( $msg ); + wmf_common_set_message_source( $msg, 'direct', 'Offline importer: ' . get_class( $this ) ); return $msg; } @@ -210,17 +210,6 @@ $msg['gateway_txn_id'] = md5( $msg['date'] . $name_salt . $this->row_index ); } } - } - - protected function setSourceData( &$msg ) { - $msg = array_merge( $msg, array( - 'source_type' => 'direct', - 'source_name' => 'Offline importer: ' . get_class($this), - 'source_host' => gethostname(), - 'source_run_id' => getmypid(), - 'source_version' => wmf_common_get_my_revision(), - 'source_enqueued_time' => time(), - ) ); } /** diff --git a/sites/all/modules/recurring_globalcollect/recurring_globalcollect.module b/sites/all/modules/recurring_globalcollect/recurring_globalcollect.module index 7a0585b..27f8815 100644 --- a/sites/all/modules/recurring_globalcollect/recurring_globalcollect.module +++ b/sites/all/modules/recurring_globalcollect/recurring_globalcollect.module @@ -368,13 +368,6 @@ $msg['contribution_tags'] = isset( $options['contribution_tags'] ) ? $options['contribution_tags'] : array(); - $msg['source_type'] = "direct"; - $msg['source_name'] = "Recurring GlobalCollect"; - $msg['source_host'] = gethostname(); - $msg['source_version'] = wmf_common_get_my_revision(); - $msg['source_run_id'] = getmypid(); - $msg['source_enqueued_time'] = time(); // ARGH - $msg['contact_id'] = $contribution_recur['contact_id']; $msg['contribution_recur_id'] = $contribution_recur['id']; $msg['effort_id'] = $values['effort_id']; @@ -382,6 +375,8 @@ //FIXME: ignored cos we already have a contact $msg['email'] = 'nob...@wikimedia.org'; + wmf_common_set_message_source( $msg, 'direct', 'Recurring GlobalCollect' ); + $contribution = wmf_civicrm_contribution_message_import( $msg ); $contribution['contribution_id'] = $contribution['id']; diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module b/sites/all/modules/wmf_civicrm/wmf_civicrm.module index c15e9ad..92119d5 100644 --- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module +++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module @@ -1505,14 +1505,11 @@ 'parent_contribution_id' => $contribution->id, 'finance_only' => 1, 'no_thank_you' => 'refund', - - 'source_type' => 'direct', - 'source_name' => "Refund", - 'source_host' => gethostname(), - 'source_run_id' => getmypid(), - 'source_version' => wmf_common_get_my_revision(), - 'source_enqueued_time' => wmf_common_date_unix_to_sql( time() ), ); + + wmf_common_set_message_source( $custom_values, 'direct', 'Refund' ); + $custom_values['source_enqueued_time'] = wmf_common_date_unix_to_sql( $custom_values['source_enqueued_time'] ); + wmf_civicrm_set_custom_field_values($refund->id, $custom_values); $custom_values = array( diff --git a/sites/all/modules/wmf_common/wmf_common.module b/sites/all/modules/wmf_common/wmf_common.module index ee057f2..9cc8ba1 100644 --- a/sites/all/modules/wmf_common/wmf_common.module +++ b/sites/all/modules/wmf_common/wmf_common.module @@ -333,3 +333,12 @@ // LOL return strtolower( str_replace( '_', '-', $locale ) ); } + +function wmf_common_set_message_source( &$msg, $type, $name ) { + $msg['source_type'] = $type; + $msg['source_name'] = $name; + $msg['source_host'] = gethostname(); + $msg['source_version'] = wmf_common_get_my_revision(); + $msg['source_run_id'] = getmypid(); + $msg['source_enqueued_time'] = time(); +} -- To view, visit https://gerrit.wikimedia.org/r/149777 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I39503ee4d80348c782a922dff2cc2c031ad4a603 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits