-
-
Notifications
You must be signed in to change notification settings - Fork 805
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
Add cancel_reason field in contribute query whereClauseSingle #12761
Conversation
Did a quick testing on search forms. It fixes the main issue and code changes looks fine to me. |
@@ -258,6 +258,7 @@ public static function whereClauseSingle(&$values, &$query) { | |||
case (strpos($name, '_amount') !== FALSE): | |||
case (strpos($name, '_date') !== FALSE && $name != 'contribution_fulfilled_date'): | |||
case 'contribution_campaign_id': | |||
case 'contribution_cancel_reason': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why do we need to add case for every contribution field of type varchar? Doesn't the default section responsible to handle this automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default: section doesn't take care properly of string fields. If you see the result query, it adds where clause civicrm_contribution.financial_type_id IN ("3", "1", "4","2")
when it's not necessary, and then the IN operator it's not parsed properly
Basically, I added cancel_reason in the same case block as other string field are parsed properly, like contribution_source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But i still think we should fix the default section rather than adding additional case as it will break in future if anyone wants to add additional filter through hook.
I believe civicrm_contribution.financial_type_id IN ("3", "1", "4","2")
is needed when ACL Financial type is enabled but shouldn't be on default section as it will keep adding same clause.
I am not sure why cancel reason is treated as IN operator rather 'LIKE' or '='
@eileenmcnaughton @monishdeb thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the default section should work / be fixed. The switch statement mostly exists because of bad coding historically.
-We should really get a test on it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I agree as well that the proper fix is to correct default: code block. But for that fix I'm afraid I won't be able to take the lead to make a new PR
Refactoring that, might have a big impact on the whole Contribution Query class, and every piece of code / feature that's related with it, and I don't think I'm confident on how to fix it properly
This PR #12775 fixes the issue. Closing! |
Overview
Contribution's Cancel Reason is not working when used in Search Builder using IN operator
Before
Query produced is wrong
After
Technical Details
cancel_reason field is not treated as rest of contribution's fields in whereClauseSingle().
This PR just add this field to be treated as the rest of common contribution's fields