Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#149 - Fatal Error on customvalue get api #12225

Merged
merged 2 commits into from
Jun 1, 2018

Conversation

jitendrapurohit
Copy link
Contributor

Overview

Fix fatal error on custom value get api.

Before

Custom Value get API fails with a fatal error.

$result = civicrm_api3('CustomValue', 'get', [
  'sequential' => 1,
  'return' => "custom_1",
  'entity_id' => 202,
]];

Result -

"is_error": 1,
"error_message": "A fatal error was triggered:  is not of type String"

After

Fixed.

Technical Details

Incorrect parameter passed in civicrm_api3_custom_value_get() fucntion.

Comments

Added unit test.


Gitlab Issue - https://lab.civicrm.org/dev/core/issues/149

@colemanw
Copy link
Member

colemanw commented May 29, 2018

The existing code seems to be supporting a syntax like:

$result = civicrm_api3('CustomValue', 'get', [
  'return.custom_1' => 1,
  'return.custom_2' => 1,
  'return.custom_3' => 1,
  'entity_id' => 202,
]];

I suspect this change will break any code using that syntax.

If we want to support the alternate syntax of 'return' => ['custom_1', 'custom_2', 'custom_3'] then that would be fine, but this PR doesn't seem to do that.

@jitendrapurohit
Copy link
Contributor Author

Updated the PR to support all the return value syntax. Thanks @colemanw

$returnValues = [
['return' => "custom_{$customId}"],
['return' => ["custom_{$customId}"]],
["return.custom_{$customId}" => 1],
Copy link
Member

@colemanw colemanw May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also add 2 more scenarios to this test?

  1. Multiple fields to return (array format)
  2. Multiple fields to return ('return.custom_x' => 1 format)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated unit test to cover above scenarios as well 👍

@colemanw
Copy link
Member

colemanw commented Jun 1, 2018

Test coverage is good now. Merging.

@colemanw colemanw merged commit 887ef31 into civicrm:master Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants