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
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 'email@example.com' 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' => "firstname.lastname@example.org", 'contact_id' => 205, 'domain_id' => 1, ]); // Second UFMatch API update. $result = civicrm_api3('UFMatch', 'create', [ 'uf_id' => 5, 'uf_name' => "email@example.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.