From c965b7e0eb3d69f0c8fdfd57273de56e9984d68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 21 Feb 2025 15:36:11 +0100 Subject: [PATCH] #46 Use entity manager clear instead of detach --- src/Monolog/Handler/DoctrineProcessHandler.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Monolog/Handler/DoctrineProcessHandler.php b/src/Monolog/Handler/DoctrineProcessHandler.php index 07c4a0a..3ed374b 100644 --- a/src/Monolog/Handler/DoctrineProcessHandler.php +++ b/src/Monolog/Handler/DoctrineProcessHandler.php @@ -59,9 +59,7 @@ public function flush(): void } } $this->em?->flush(); - foreach ($this->records as $record) { - $this->em?->detach($record); - } + $this->em?->clear(); $this->records = new ArrayCollection(); } @@ -70,6 +68,7 @@ protected function write(LogRecord $record): void $this->records->add($record); if (500 === $this->records->count()) { $this->flush(); + $this->em?->clear(); } } }