CiviCRM 5.51.1 APIv4 bug querying tag by name incorrectly returns untagged Contacts when executed by Anonymous but correctly returns tagged Contacts for Authenticated Users
CiviCRM 5.51.1 APIv4 bug querying tag by name incorrectly returns untagged Contacts when executed by Anonymous but correctly returns tagged Contacts for Authenticated Users. Check Permissions is FALSE for the API call. This was working in CiviCRM 5.49.1.
Using CiviCRM 5.49.1, the APIv4 query used the following WHERE clause:
$contacts = \Civi\Api4\Contact::get(FALSE)
...
->addWhere('tags:name', 'IN', [9, 'Professional Member'])
As of CiviCRM 5.51.1, this started returning different results for Anonymous versus logged in Authenticated Users. Despite the Check Permissions being FALSE for the API call.
In CiviCRM 5.51.1, this WHERE clause DOES work.
$contacts = \Civi\Api4\Contact::get(FALSE)
...
->addWhere('tags', 'IN', [9])
Also should be noted that this WHERE clause does NOT work either.
$contacts = \Civi\Api4\Contact::get(FALSE)
...
->addWhere('tags:name', 'IN', 'Professional Member')
Agileware Ref: CIVICRM-2019