transitionParticipants() - Improve $contactDetails cache maintenance
authorTim Otten <totten@civicrm.org>
Thu, 4 Nov 2021 03:26:27 +0000 (20:26 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 4 Nov 2021 03:26:27 +0000 (20:26 -0700)
This revises a very recent commit that touches `static $contactDetails` cache.

Imagine you have two calls to `transitionParticipants()` which involve different-but-overlapping sets:

* First invocation involves Alice and Bob
* Second invocation involves Bob and Carol

The first invocation loads Alice and Bob into `$contactDetails`.  The second
invocation identifies Carol as missing. We need to load Carol. Here's the change:

* Before: Carol overwrites Bob in `$contactDetails`. Bob goes missing.
* After: Alice, Bob, and Carol all exist in `$contactDetails`.

CRM/Event/BAO/Participant.php

index 618927d8c5688fc97635f649b7a2f4f6c14db82b..1964f754632d65268996ede4975d765eda0b3d5b 100644 (file)
@@ -1236,7 +1236,7 @@ UPDATE  civicrm_participant
 
     //get all required contacts detail.
     if (!empty($contactIds)) {
-      $contactDetails = civicrm_api3('Contact', 'get', ['id' => ['IN' => $contactIds, 'return' => 'display_name']])['values'];
+      $contactDetails += civicrm_api3('Contact', 'get', ['id' => ['IN' => $contactIds, 'return' => 'display_name']])['values'];
     }
 
     //get all required events detail.