From ee81a274b52b5d320c207bf9f2fbd1ce7c569603 Mon Sep 17 00:00:00 2001 From: Jens Schuppe Date: Fri, 29 Jul 2022 15:47:28 +0200 Subject: [PATCH] Find DAO by ID instead of just calling the constructor and setting the ID Otherwise, finding references might fail because of missing entity values when comparing, e.g. `option_group_id` for OptionVaue BAOs. --- Civi/Api4/Generic/ExportAction.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Civi/Api4/Generic/ExportAction.php b/Civi/Api4/Generic/ExportAction.php index 87cd3c5048e9..b7e73717960e 100644 --- a/Civi/Api4/Generic/ExportAction.php +++ b/Civi/Api4/Generic/ExportAction.php @@ -159,8 +159,7 @@ private function exportRecord(string $entityType, int $entityId, Result $result, $daoName = CoreUtil::getInfoItem($entityType, 'dao'); if ($daoName) { /** @var \CRM_Core_DAO $dao */ - $dao = new $daoName(); - $dao->id = $entityId; + $dao = $daoName::findById($entityId); // Collect references into arrays keyed by entity type $references = []; foreach ($dao->findReferences() as $reference) {