Avoid duplicate Contact Subtypes
Adding duplicate Contact Subtypes to a Contact isn't possible via the CiviCRM admin UI or the API Explorer and therefore shouldn't be possible when calling the API in code - but it is:
$result = civicrm_api3('Contact', 'get', [
'id' => 205,
'contact_sub_type' => ["Staff", "Staff", "Staff"],
]);
This results in:
[contact] => Array
(
[contact_id] => 205
[contact_type] => Individual
[contact_sub_type] => Array
(
[0] => Staff
[1] => Staff
[2] => Staff
)
... more data ...
In CiviRules, when multiple rules which add the same Contact Subtype run, duplicate Contact Subtypes are added to the Contact. This shouldn't happen.
PR to follow.