Skip to content

UFMatch fixes and improvements

haystack requested to merge haystack/multisite:ufmatch into master

Here are a couple of UFMatch improvements:

Commit e0e20f1e fixes a situation where there are other callbacks for civicrm_post that need full UFMatch data in order to function. The current code causes contact_id, uf_id and domain_id to be missing in the callback data. Furthermore, domain_id must be passed to the API calls otherwise there will be errors of the form Duplicate entry 'foo@bar.com-2' for key 'UI_uf_name_domain_id'.

Commit e0e20f1e fixes situations such as demonstrated by the following snippet:

// First UFMatch API update.
$result = civicrm_api3('UFMatch', 'create', [
  'uf_id' => 2,
  'uf_name' => "foo@bar.com",
  'contact_id' => 205,
  'domain_id' => 1,
]);

// Second UFMatch API update.
$result = civicrm_api3('UFMatch', 'create', [
  'uf_id' => 5,
  'uf_name' => "bar@foo.com",
  'contact_id' => 210,
  'domain_id' => 1,
]);

Currently, the UFMatch updates in multisite_civicrm_post() will only run once (for Contact ID 205) but not for the subsequent UFMatch update for Contact ID 210. e0e20f1e is not a complete fix (e.g. it will skip another UFMatch update for a Contact ID that has already been processed) but it's a step in the right direction.

Merge request reports