From 9ca4c4430035de124d4a68e67a039ad0d66fcd34 Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Fri, 6 Dec 2024 17:32:58 -0800 Subject: [PATCH] Fix announcements display; move to Carbon instead of strings for date representations --- classes/announcement/Announcement.php | 9 ++++++--- pages/index/PKPIndexHandler.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/classes/announcement/Announcement.php b/classes/announcement/Announcement.php index 2d88f6e096d..3f1ebe2d609 100644 --- a/classes/announcement/Announcement.php +++ b/classes/announcement/Announcement.php @@ -1,4 +1,5 @@ where('date_expire', '>', empty($date) ? Core::getCurrentDate() : $date) + return $builder->where('date_expire', '>', $date ?? Carbon::now()) ->orWhereNull('date_expire'); } diff --git a/pages/index/PKPIndexHandler.php b/pages/index/PKPIndexHandler.php index 9a19b58f2db..94fe5f38e99 100644 --- a/pages/index/PKPIndexHandler.php +++ b/pages/index/PKPIndexHandler.php @@ -46,7 +46,7 @@ protected function _setupAnnouncements(Context|Site $contextOrSite, $templateMgr $announcements->withContextIds($contextIds); $templateMgr->assign([ - 'announcements' => $announcements->get()->toArray(), + 'announcements' => $announcements->get(), 'numAnnouncementsHomepage' => $numAnnouncementsHomepage, ]); }