dev/core#2162: allow reports to filter multi-select fields and find entities with multiple selections #18978
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.
Currently, Reports which filter on multi-select fields will only find entities with single selections. The generated SQL syntax is not compatible with the storage format of multi-select custom fields.
Overview
Here is the issue which this fix addresses:
https://lab.civicrm.org/dev/core/-/issues/2162
The detailed description and reproduction steps are documented there.
Before
Contacts with multiple selections in a multi-select custom field would never appear in a Report which filters on that custom field. I believe this is a regression, though I haven't worked out exactly when it changed.
After
With this change, reports can filter correctly on these fields.
Technical Details
The addCustomDataToColumns function constructs a $customDAO object, which is then used to determine the operator (among other things). It wasn't fetching the civicrm_custom_field.serialize field when it constructed this object, so it concluded that custom fields are never serialized.
By fetching this field, it appears to function as intended.
Comments
When I wrote the initial issue description, I was under the impression that the change may have been deliberate. I now think that it was probably accidental, and reports filtering for "is one of" a multi-select field should find entities with more than one selection.