DAO - Prevent recursion adding acl clause to entity that references itself
authorcolemanw <coleman@civicrm.org>
Tue, 12 Sep 2023 16:30:01 +0000 (12:30 -0400)
committercolemanw <coleman@civicrm.org>
Tue, 12 Sep 2023 16:30:01 +0000 (12:30 -0400)
CRM/Core/DAO.php

index 3faae6f7235b1f8388a3b05fe96ad1832aaefbe1..b980479fcbdf980d5069719d8f9e1fa2e0249a5b 100644 (file)
@@ -3097,7 +3097,8 @@ SELECT contact_id
     $relatedClauses = [];
     $relatedEntities = static::buildOptions('entity_table', 'get');
     foreach ((array) $relatedEntities as $table => $ent) {
-      if (!empty($ent)) {
+      // Prevent recursion
+      if (!empty($ent) && $table !== static::getTableName()) {
         $ent = CRM_Core_DAO_AllCoreTables::getEntityNameForTable($table);
         $subquery = CRM_Utils_SQL::mergeSubquery($ent);
         if ($subquery) {