From 15f8432ce06e24d83b0fa5a4822bed8a17e5997b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 29 Nov 2023 11:30:14 +0100 Subject: [PATCH 1/3] Use PostUpdateEventArgs typing instead of PostPersistEventArgs --- .../Notification/Counter/NotificationByUserCounter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php index 81a8bb3bb..15a33d836 100644 --- a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php @@ -16,7 +16,7 @@ use Chill\MainBundle\Entity\NotificationComment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\NotificationRepository; use Chill\MainBundle\Templating\UI\NotificationCounterInterface; -use Doctrine\ORM\Event\PostPersistEventArgs; +use Doctrine\ORM\Event\PostUpdateEventArgs; use Doctrine\ORM\Event\PreFlushEventArgs; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -62,7 +62,7 @@ final readonly class NotificationByUserCounter implements NotificationCounterInt return 'chill_main_notif_unread_by_'.$user->getId(); } - public function onEditNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void + public function onEditNotificationComment(NotificationComment $notificationComment, PostUpdateEventArgs $eventArgs): void { $this->resetCacheForNotification($notificationComment->getNotification()); } From d58c0a867d38887f4524623e9b106fbbdc72d5f6 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 29 Nov 2023 11:31:53 +0100 Subject: [PATCH 2/3] add changie --- .changes/unreleased/Fixed-20231129-113138.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Fixed-20231129-113138.yaml diff --git a/.changes/unreleased/Fixed-20231129-113138.yaml b/.changes/unreleased/Fixed-20231129-113138.yaml new file mode 100644 index 000000000..efe9b10c1 --- /dev/null +++ b/.changes/unreleased/Fixed-20231129-113138.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix error in logs about wrong typing of eventArgs in onEditNotificationComment + method +time: 2023-11-29T11:31:38.933538592+01:00 +custom: + Issue: "220" From 32ae2f8f0df7ea9de3510a75a41024357b66b90c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 13 Dec 2023 10:12:56 +0100 Subject: [PATCH 3/3] Add a separate method for onPersist, use same private resetCache method --- .../Notification/Counter/NotificationByUserCounter.php | 6 ++++++ .../ChillMainBundle/config/services/notification.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php index 15a33d836..e08543e8c 100644 --- a/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php +++ b/src/Bundle/ChillMainBundle/Notification/Counter/NotificationByUserCounter.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\NotificationComment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\NotificationRepository; use Chill\MainBundle\Templating\UI\NotificationCounterInterface; +use Doctrine\ORM\Event\PostPersistEventArgs; use Doctrine\ORM\Event\PostUpdateEventArgs; use Doctrine\ORM\Event\PreFlushEventArgs; use Psr\Cache\CacheItemPoolInterface; @@ -62,6 +63,11 @@ final readonly class NotificationByUserCounter implements NotificationCounterInt return 'chill_main_notif_unread_by_'.$user->getId(); } + public function onPersistNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void + { + $this->resetCacheForNotification($notificationComment->getNotification()); + } + public function onEditNotificationComment(NotificationComment $notificationComment, PostUpdateEventArgs $eventArgs): void { $this->resetCacheForNotification($notificationComment->getNotification()); diff --git a/src/Bundle/ChillMainBundle/config/services/notification.yaml b/src/Bundle/ChillMainBundle/config/services/notification.yaml index 29cbce946..be3252003 100644 --- a/src/Bundle/ChillMainBundle/config/services/notification.yaml +++ b/src/Bundle/ChillMainBundle/config/services/notification.yaml @@ -41,7 +41,7 @@ services: entity: 'Chill\MainBundle\Entity\NotificationComment' # set the 'lazy' option to TRUE to only instantiate listeners when they are used lazy: true - method: 'onEditNotificationComment' + method: 'onPersistNotificationComment' Chill\MainBundle\Notification\Email\NotificationMailer: autowire: true