Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/383260 )
Change subject: WIP Check contact_hash if contact_id exists ...................................................................... WIP Check contact_hash if contact_id exists TODO: tests Bug: T177663 Change-Id: Id8bbd8711b6742b99a552e363fe604b73df33385 --- M sites/all/modules/wmf_civicrm/wmf_civicrm.module 1 file changed, 21 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm refs/changes/60/383260/1 diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module b/sites/all/modules/wmf_civicrm/wmf_civicrm.module index 50eaab3..f6b065c 100644 --- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module +++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module @@ -223,7 +223,27 @@ } } - if ( !$msg['contact_id'] ) { + $createNewContact = true; + if (!empty($msg['contact_id'])) { + $createNewContact = false; + // TODO: chase down merge targets for deleted contacts + if (isset($msg['contact_hash'])) { + // This message came from the donations front-end. We need to verify + // the hash before using the existing contact. + $existing = civicrm_api3('Contact', 'getSingle', array( + 'id' => $msg['contact_id'], + 'return' => 'hash' + )); + // If the contact doesn't exist, or the hash doesn't match, act like + // it's a new donor. + if (!$existing || $existing['hash'] !== $msg['contact_hash']) { + $createNewContact = true; + unset($msg['contact_id']); + unset($msg['contact_hash']); + } + } + } + if ( $createNewContact ) { wmf_civicrm_message_create_contact($msg); } else { -- To view, visit https://gerrit.wikimedia.org/r/383260 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id8bbd8711b6742b99a552e363fe604b73df33385 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits