From: Seamus Lee Date: Mon, 30 Aug 2021 01:07:12 +0000 (+1000) Subject: [REF] Improve Custom data insert performance when using the copyCustomFields X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=11201e1775371b65ecd4c310fdbc4f945f915358;p=civicrm-core.git [REF] Improve Custom data insert performance when using the copyCustomFields --- diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index f158a0f19d..fa5373b087 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -396,15 +396,16 @@ class CRM_Core_BAO_CustomValueTable { * @param $entityTable * @param int $entityID * @param $customFieldExtends + * @param $parentOperation */ - public static function postProcess(&$params, $entityTable, $entityID, $customFieldExtends) { + public static function postProcess(&$params, $entityTable, $entityID, $customFieldExtends, $parentOperation = NULL) { $customData = CRM_Core_BAO_CustomField::postProcess($params, $entityID, $customFieldExtends ); if (!empty($customData)) { - self::store($customData, $entityTable, $entityID); + self::store($customData, $entityTable, $entityID, $parentOperation); } } diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 5bb34367c7..35b26c4b23 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1975,7 +1975,7 @@ LIKE %1 public function copyCustomFields($entityID, $newEntityID) { $entity = CRM_Core_DAO_AllCoreTables::getBriefName(get_class($this)); $tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(get_class($this)); - // Obtain custom values for old event + // Obtain custom values for the old entity. $customParams = $htmlType = []; $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($entityID, $entity); @@ -2009,8 +2009,8 @@ LIKE %1 } } - // Save Custom Fields for new Event - CRM_Core_BAO_CustomValueTable::postProcess($customParams, $tableName, $newEntityID, $entity); + // Save Custom Fields for new Entity. + CRM_Core_BAO_CustomValueTable::postProcess($customParams, $tableName, $newEntityID, $entity, 'create'); } // copy activity attachments ( if any )