From 60be1f25adf01468af200a6cf0d81758dc5c9783 Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Mon, 28 Oct 2024 14:20:36 -0500 Subject: [PATCH] Internal: Fix role check in SendEventRemindersCommand - refs BT#22151 --- src/CoreBundle/Command/SendEventRemindersCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/Command/SendEventRemindersCommand.php b/src/CoreBundle/Command/SendEventRemindersCommand.php index 13a79e5677..952bbd1417 100644 --- a/src/CoreBundle/Command/SendEventRemindersCommand.php +++ b/src/CoreBundle/Command/SendEventRemindersCommand.php @@ -131,8 +131,11 @@ class SendEventRemindersCommand extends Command private function getFirstAdminId(): int { - $admin = $this->entityManager->getRepository(User::class)->findOneByRole('ROLE_ADMIN'); - return $admin ? $admin->getId() : 1; + $admin = $this->entityManager->getRepository(User::class)->findOneBy([]); + if ($admin && ($admin->hasRole('ROLE_ADMIN') || $admin->hasRole('ROLE_SUPER_ADMIN'))) { + return $admin->getId(); + } + return 1; } private function generateEventDetails(CCalendarEvent $event): string