Skip to content

Commit

Permalink
Set deleted collection only to the owner and be able to skip doctrine…
Browse files Browse the repository at this point in the history
… collections fields
  • Loading branch information
Louis Fortunier committed Sep 24, 2024
1 parent 4801ab7 commit 5dc28bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**
Expand Down
6 changes: 5 additions & 1 deletion src/EventListener/HistoryDoctrineListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 5dc28bc

Please sign in to comment.