diff --git a/CHANGELOG.md b/CHANGELOG.md index c4916a1..a30f956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ CHANGELOG for 1.x =================== +## v1.13.1 - (2024-09-24) +### Fixed +- `HistoryDoctrineListener::handleHistory` set deleted collection only to the owner + +### Added +- `HistorizableInterface::getHistoryDiffFieldsToSkip` be able to skip doctrine collections fields in `HistoryDoctrineListener::handleHistory` + ## v1.13.0 - (2024-09-24) ### Added - `EntityCleanupCommand` to delete cron, clean api calls or other entity easily through the bundle configuration **entity_cleanup_command_configs** diff --git a/src/EventListener/HistoryDoctrineListener.php b/src/EventListener/HistoryDoctrineListener.php index fec35da..f70964d 100644 --- a/src/EventListener/HistoryDoctrineListener.php +++ b/src/EventListener/HistoryDoctrineListener.php @@ -91,7 +91,7 @@ private function handleHistory(LifecycleEventArgs $args, string $code): void $uow = $args->getObjectManager()->getUnitOfWork(); $entityClass = get_class($entity); foreach ($uow->getScheduledCollectionUpdates() as $collection) { - if ($entityClass !== get_class($collection->getOwner())) { + if ($entityClass !== get_class($collection->getOwner()) || isset($diffFieldsToSkip[$collection->getMapping()['fieldName']])) { continue; } // MDT the 'c_u' string is a shortcut index key meaning collection_update @@ -102,6 +102,10 @@ private function handleHistory(LifecycleEventArgs $args, string $code): void // MDT the preUpdate event is not triggered if the only modification of the event concerns the deletion of the collection // cf. https://github.com/doctrine/orm/issues/9960 foreach ($uow->getScheduledCollectionDeletions() as $collection) { + if ($entityClass !== get_class($collection->getOwner()) || isset($diffFieldsToSkip[$collection->getMapping()['fieldName']])) { + continue; + } + $entityData[$collection->getMapping()['fieldName']] = 'label.empty'; } $historyData[HistoryLogger::DIFF_PROPERTY] = $entityData;