Find DAO by ID instead of just calling the constructor and setting the ID
authorJens Schuppe <schuppe@systopia.de>
Fri, 29 Jul 2022 13:47:28 +0000 (15:47 +0200)
committerJens Schuppe <schuppe@systopia.de>
Fri, 29 Jul 2022 13:47:28 +0000 (15:47 +0200)
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

index 87cd3c5048e96befd289d59d892a091852a7bb7f..b7e73717960ef36592aed1f02ee26d5f1b4ab2c5 100644 (file)
@@ -159,8 +159,7 @@ class ExportAction extends AbstractAction {
     $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) {