regression: Custom searches are completely broken when used as smart groups
I'm attaching a video that demonstrates the replication steps, but:
- Create a new custom search.
- The results of the search are correct.
- Save the results as a smart group.
- View the smart group.
- The smart group contains all contacts. broken_custom_searches
This led to someone emailing all contacts in their database on a CiviMail, which they're predictably taking seriously.
I traced the issue and found that at
CRM_Contact_BAO_GroupContactCache::insertGroupContactsIntoTempTable(), there's an if statement that looks like it should evaluate to
TRUE that evaluates to
FALSE but forcing it to
TRUE doesn't solve the problem.