Search for petition activities returns extraneous results
Overview
When searching for petition activities in Advanced Search or Activities Search, selecting only a particular petition returns extraneous activities which are not of type Petition.
The extraneous activities have the same id number as the petition specified in the search criteria, but they include other activity types, e.g. Contribution, Membership signup, Event Registration.
Reproduction steps
- Go to https://dmaster.demo.civicrm.org
- Create a petition.
- Click Search | Find Activities
- In the Survey/Petition dropdown, select the newly created petition .
- Click Search
Current behaviour
The results include a Contribution, a Membership signup, and an Event Registration.
Expected behaviour
The results should include only activities for the specified petition.
Environment information
- CiviCRM: 5.49.alpha1.
Comments
When searching for Activities, the bug is fairly obvious by a casual inspection of the results table. When searching for Contacts in Advanced Search, the bug is far more insidious.
While very useful, the very existence of the Survey/Petition dropdown creates an inconsistency or ambiguity in the UI. Given that the search conditions specified by each control are generally ANDed, but the Survey/Petition dropdown is really a subset of the Activity Type dropdown, it's not clear what results should be expected in the case of selecting, for example, Activity Type = "Contribution" along with a specific survey/petition. Do we want this to be an unwritten exception to the rule in which the criteria is ORed instead of ANDed? If the answer is no, then I think the best solution would be to disable the Survey/Petition dropdown unless Activity Type specifies exactly either Petition or Survey. In that case the Petition/Survey box should be enabled and display either Petitions or Surveys. Making this change to the UI provides two benefits:
- Avoids ambiguity in the expected results.
- Produces the expected search results without having to modify the search logic.
An alternative solution would be to leave the UI as is, and modify the search logic to consider the implied Activity Type when selecting an item from the Survey/Petition dropdown. This provides more flexibility when searching, as it would (should?) support ORing additional activity types. While this creates an inconsistency in the UI rules, it is arguably an "intuitive" inconsistency.