CRM-20866: Soft credit appearance inconsistent in contribution search #11433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
First search for contributions with field "Contributions OR Soft Credits?" set to "Soft Credits Only" does not show soft credit data. Columns "Soft Credit Amount", "Soft Credit For" and "Soft Credit Type" are empty. Thus, soft credits appear as regular contributions.
Subsequent searches include data for those columns.
Before
After
With this fix all searches for soft credits include that data.
Technical Details
There's a static variable
CRM_Contribute_BAO_Query::$_contribOrSoftCredit
that causes this inconsistent behaviour. It only works under certain conditions (when form values are already in$_SESSION
data duringCRM_Contribute_Form_Search::preProcess
). I've decided to add additional parameter toCRM_Contribute_BAO_Query::selectorReturnProperties
, so that it wouldn't rely on static variable being set beforehand.I've included a small unit test, which asserts that the soft data fields are added to SELECT statement.