* better or worse )
*
* @return array|int
- *
- * @throws \CRM_Core_Exception
*/
public function callAPISuccess($entity, $action, $params = [], $checkAgainst = NULL) {
$params = array_merge([
$params += [
'version' => $this->_apiversion,
];
+ if (!empty($this->isGetSafe) && !isset($params['return'])) {
+ $params['return'] = 'id';
+ }
$result = $this->civicrm_api($entity, 'getsingle', $params);
if (!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
$unfilteredResult = $this->civicrm_api($entity, 'get', ['version' => $this->_apiversion]);
$onlyId = !empty($v3Params['format.only_id']);
$onlySuccess = !empty($v3Params['format.is_success']);
if (!empty($v3Params['filters']['is_current']) || !empty($v3Params['isCurrent'])) {
- $v4Params['current'] = TRUE;
+ $v3Params['is_current'] = 1;
+ unset($v3Params['filters']['is_current'], $v3Params['isCurrent']);
}
$language = $v3Params['options']['language'] ?? $v3Params['option.language'] ?? NULL;
if ($language) {
$v4Params['language'] = $language;
}
$toRemove = ['option.', 'return', 'api.', 'format.'];
- $chains = $joins = $custom = [];
+ $chains = $custom = [];
foreach ($v3Params as $key => $val) {
foreach ($toRemove as $remove) {
if (strpos($key, $remove) === 0) {
// This is a per field hack (bad) but we can't solve everything at once
// & a cleverer way turned out to be too much for this round.
// Being in the test class it's tested....
- $v3Params['option_group.name'] = $v3Params['option_group_id'];
+ $v3Params['option_group_id.name'] = $v3Params['option_group_id'];
unset($v3Params['option_group_id']);
}
if (isset($field['pseudoconstant'], $v3Params[$name]) && $field['type'] === \CRM_Utils_Type::T_INT && !is_numeric($v3Params[$name]) && is_string($v3Params[$name])) {
if ($v4Entity != 'Setting' && !in_array('id', $v4Params['select'])) {
$v4Params['select'][] = 'id';
}
- // Convert join syntax
- foreach ($v4Params['select'] as $idx => $select) {
- if (strstr($select, '_id.')) {
- $joins[$select] = $v4Params['select'][$idx] = str_replace('_id.', '.', $select);
- }
- }
}
if ($options['limit'] && $v4Entity != 'Setting') {
$v4Params['limit'] = $options['limit'];
foreach ($chains as $key => $params) {
$result[$index][$key] = $this->runApi4LegacyChain($key, $params, $v4Entity, $row, $sequential);
}
- // Convert join format
- foreach ($joins as $api3Key => $api4Key) {
- $result[$index][$api3Key] = $result[$index][$api4Key] ?? NULL;
- }
// Resolve custom field names
foreach ($custom as $group => $fields) {
foreach ($fields as $field => $v3FieldName) {