Skip to content

Commit

Permalink
transitionParticipants() - Improve $contactDetails cache maintenance
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
totten committed Nov 4, 2021
1 parent 943c6d0 commit 9729866
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ public static function transitionParticipants(

//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.
Expand Down

0 comments on commit 9729866

Please sign in to comment.