APIv4 - Fix missing tag filer on Individual,Organization,Household entities
authorcolemanw <coleman@civicrm.org>
Fri, 10 Nov 2023 18:59:01 +0000 (13:59 -0500)
committercolemanw <coleman@civicrm.org>
Fri, 10 Nov 2023 18:59:01 +0000 (13:59 -0500)
Civi/Api4/Service/Spec/Provider/EntityTagFilterSpecProvider.php
tests/phpunit/api/v4/Entity/TagTest.php

index bdc05f6810aee19a0f58b006c0f7167c08a3cb2a..1479819acfd5dc9e7c5ea32e238895e17cc1f0c4 100644 (file)
@@ -53,6 +53,9 @@ class EntityTagFilterSpecProvider extends \Civi\Core\Service\AutoService impleme
     if ($action !== 'get') {
       return FALSE;
     }
+    if (CoreUtil::isContact($entity)) {
+      return TRUE;
+    }
     $usedFor = \CRM_Core_OptionGroup::values('tag_used_for', FALSE, FALSE, FALSE, NULL, 'name');
     return in_array($entity, $usedFor, TRUE);
   }
index 023d9c3322575f00ed6289c6f93a9ea079645019..379789caf998cfdc1edc515165209922041c3021 100644 (file)
@@ -21,6 +21,7 @@ namespace api\v4\Entity;
 use Civi\Api4\Contact;
 use api\v4\Api4TestBase;
 use Civi\Api4\EntityTag;
+use Civi\Api4\Individual;
 use Civi\Api4\Tag;
 use Civi\Test\TransactionalInterface;
 
@@ -79,7 +80,7 @@ class TagTest extends Api4TestBase implements TransactionalInterface {
     $this->assertCount(1, $shouldReturnContact1);
     $this->assertEquals($contact1['id'], $shouldReturnContact1->first()['id']);
 
-    $shouldReturnContact2 = Contact::get(FALSE)
+    $shouldReturnContact2 = Individual::get(FALSE)
       ->addSelect('id')
       ->addWhere('tags', 'IN', [$setChild['id']])
       ->execute();