Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG for 1.x
===================
## v1.19.0 - (2026-06-19)
### Added
- Automatic history reset on entity archive. If some archive behaviors in your project should not trigger this reset, override the `resetOnArchive` method on the relevant entity.

## v1.18.2 - (2026-06-12)
### Removed
- Monitoring route `/phpinfo` removed because of security concern
Expand Down
4 changes: 4 additions & 0 deletions src/Entity/Log/HistorizableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public function isDoctrineListenerEnable(): bool;
* ]
*/
public function getHistoryDiffFieldsToSkip(): array;

public function resetHistory(): self;

public function resetOnArchive(): bool;
Comment thread
mathieu-ducrot marked this conversation as resolved.
}
12 changes: 12 additions & 0 deletions src/Entity/Log/HistorizableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ public function getHistoryDiffFieldsToSkip(): array
{
return [];
}

public function resetHistory(): self
{
$this->setHistory(null);

return $this;
}

public function resetOnArchive(): bool
{
return true;
}
}
9 changes: 9 additions & 0 deletions src/Logger/HistoryLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public function isFlushLog(): bool
*/
public function log(HistorizableInterface $entity, ?string $code = null, array $data = []): void
{
if ($code === self::ARCHIVED_CODE && $entity->resetOnArchive()) {
$entity->resetHistory();
if ($this->flushLog) {
$this->entityManager->flush();
}

return;
}

$history = array_merge([self::DATE_PROPERTY => time()], $data);
foreach (
[
Expand Down
Loading