From d28cd227d99538ea5c716856a96a8d2535ce9e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kud=C4=9Blka?= Date: Wed, 9 Aug 2023 23:47:46 +0200 Subject: [PATCH] Update ErrorLogger.php --- src/ErrorLogger.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ErrorLogger.php b/src/ErrorLogger.php index 9f7ac14..6b8cfc4 100644 --- a/src/ErrorLogger.php +++ b/src/ErrorLogger.php @@ -114,15 +114,9 @@ protected function sendEmail($message): void $maxEmailsPerDayLog = $this->directory . '/max-emails-per-day.log'; // delete file from yesterday - if (date('Y-m-d', @filemtime($maxEmailsPerDayLog)) < (new DateTime('midnight'))->format('Y-m-d')) { + if (($filemtime = @filemtime($maxEmailsPerDayLog)) && date('Y-m-d', $filemtime) < (new DateTime('midnight'))->format('Y-m-d')) { @unlink($maxEmailsPerDayLog); - } - - $logContent = @file_get_contents($maxEmailsPerDayLog); - - file_put_contents('adasd', count(file($maxEmailsPerDayLog))); - - if (count(file($maxEmailsPerDayLog)) >= $this->maxEmailsPerDay) { + } elseif (($lines = @file($maxEmailsPerDayLog)) && count($lines) >= $this->maxEmailsPerDay) { // Limit per day exceeded return; }