Activities can be linked to multiple cases. Handle caseIds being an array #13021
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This was found when submitting a drupal webform with a case and an activity and some custom code on a post hook which does an activity.get API call and then an activity.create to update the activity.
Here is an example of an API call that will give you an array for case_id:
The
\Civi\CCase\fireCaseChange function doesn't handle the case when
$caseIdsis an array, yet the callback function it calls does handle
$caseIds` being an array. The result is that PHP throws some warnings about illegal offset type and the caseId is never added to the static cache and thus gets fired multiple times.Before
CaseIds as array not handled properly, PHP warnings and case changed event fired multiple times (as not cached).
After
CaseIds as array handled properly. Cached properly and only fired once.
Technical Details
Comments