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

CRM-19543: Fix integer 0 validation for pseudoconstants #9309

Closed
wants to merge 2 commits into from

Conversation

jitendrapurohit
Copy link
Contributor

@jitendrapurohit jitendrapurohit commented Oct 21, 2016

array_search incorrectly returns the first key when integer 0 is searched on an array of strings. This creates an entity with first value of a pseudocontant.

For eg: Grant is created with Submitted status, Membership is created with New status, etc.

Update: Instead of handling it with array_search, moved this validation to a separate if check as it was failing only for 0 value.

@colemanw Any thoughts ?


@jitendrapurohit jitendrapurohit changed the title CRM-19543: Fix ingeter 0 validation for pseudoconstants WIP - CRM-19543: Fix ingeter 0 validation for pseudoconstants Oct 21, 2016
@jitendrapurohit jitendrapurohit changed the title WIP - CRM-19543: Fix ingeter 0 validation for pseudoconstants CRM-19543: Fix ingeter 0 validation for pseudoconstants Oct 21, 2016
@jitendrapurohit jitendrapurohit changed the title CRM-19543: Fix ingeter 0 validation for pseudoconstants WIP - CRM-19543: Fix ingeter 0 validation for pseudoconstants Oct 21, 2016
@jitendrapurohit jitendrapurohit changed the title WIP - CRM-19543: Fix ingeter 0 validation for pseudoconstants CRM-19543: Fix ingeter 0 validation for pseudoconstants Oct 21, 2016
@jitendrapurohit jitendrapurohit changed the title CRM-19543: Fix ingeter 0 validation for pseudoconstants CRM-19543: Fix integer 0 validation for pseudoconstants Oct 21, 2016
@colemanw
Copy link
Member

What about casting 0 to a string '0'? would that make array_search behave correctly?

@jitendrapurohit
Copy link
Contributor Author

yes, that will work, but main issue is slight different now of changing isset() to !empty() which I did in my first commit 4d1d9ae#diff-3076917760efeb467459726ebb6af282R2175 results into some test failures as it allows empty string '', empty array(), into _civicrm_api3_validate_integer() to check.

Either we can fix all of them or proceed with this separate handling approach.

@jitendrapurohit
Copy link
Contributor Author

@colemanw Can you merge this, if it looks good to you ?

@colemanw
Copy link
Member

colemanw commented Oct 25, 2016

I think the casting is a better fix, assuming the tests pass: #9320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants