Details
Description
When trying to call Case Close using CiviCRM API V3, something strange happened:
Original Case was Closed (Resolved), but all activities in it deleted
New Case was created as reassign of the original Case - to the same contact, still in status Ongoing.
I have tried to analyze this and found following:
civicrm_api3_generic_update calls Case.get using civicrm api v3 ($existing = civicrm_api($apiRequest['entity'], 'get', $seek)
It then adds the parameters to the request:
$existing = array_pop($existing['values']);
$p = array_merge($existing, $apiRequest['params']);
return civicrm_api($apiRequest['entity'], 'create', $p);
However, in $p is 'contact_id' now not a value, but array:
[contact_id] => Array
(
[1] => 1
)
Then, in _api_case_update is following code:
// check for same contact id for edit Client
if ($params['contact_id'] && !in_array($params['contact_id'], $origContactIds))
because $params['contact_id'] is not value, but array, the condition matches (even though actually contact_id and origContstsId[1] have the same value
... and mergeCases is called
I am not sure, in which place is the best to fix this issue. I am posting it here ... and for my personal reasons will implement some temporary fix.
Regards,
Dexter