Skip to content

Commit

Permalink
dev/core#149 - Fatal Error on customvalue get api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jitendra Purohit committed May 29, 2018
1 parent 3832b5e commit 3e5dbfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/v3/CustomValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function civicrm_api3_custom_value_get($params) {
foreach ($params as $id => $param) {
if ($param && substr($id, 0, 6) == 'return') {
$id = substr($id, 7);
list($c, $i) = CRM_Utils_System::explode('_', $id, 2);
list($c, $i) = CRM_Utils_System::explode('_', $param, 2);
if ($c == 'custom' && is_numeric($i)) {
$names['custom_' . $i] = 'custom_' . $i;
$id = $i;
Expand Down
16 changes: 16 additions & 0 deletions tests/phpunit/api/v3/CustomValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ public function _testCustomValue($customField, $sqlOps, $type) {
$params = array('entity_id' => $contactId, 'custom_' . $customId => $selectedValue);
$this->callAPISuccess('CustomValue', 'create', $params);

$customValue = $this->callAPISuccess('CustomValue', 'get', [
'sequential' => 1,
'return' => "custom_{$customId}",
'entity_id' => $contactId,
]);
if (is_array($selectedValue)) {
$expected = array_values($selectedValue);
$this->checkArrayEquals($expected, $customValue['values'][0]['latest']);
}
elseif ($type == 'date') {
$this->assertEquals($selectedValue, date('Ymd', strtotime(str_replace('.', '/', $customValue['values'][0]['latest']))));
}
else {
$this->assertEquals($selectedValue, $customValue['values'][0]['latest']);
}

foreach ($sqlOps as $op) {
$qillOp = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op);
switch ($op) {
Expand Down

0 comments on commit 3e5dbfd

Please sign in to comment.