From d26d4cc358cc46cda08ad490224e6efb1ae69ccf Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 10 May 2024 10:13:58 +0200 Subject: [PATCH] errorhandling if time is invalid --- application/controllers/Contestcalendar.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/application/controllers/Contestcalendar.php b/application/controllers/Contestcalendar.php index e84efe770..8b32b44bd 100644 --- a/application/controllers/Contestcalendar.php +++ b/application/controllers/Contestcalendar.php @@ -132,6 +132,11 @@ class Contestcalendar extends CI_Controller { $today = date('Y-m-d'); foreach ($rss as $contest) { + if (!($contest['start'] instanceof DateTime)) { + log_message('debug',"Invalid Time format for contest: " . $contest['title']); + continue; + } + $start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d'))); if ($start === $today) { $contestsToday[] = $contest; @@ -150,6 +155,10 @@ class Contestcalendar extends CI_Controller { $nextSunday = date('Y-m-d', strtotime('next sunday', strtotime($today))); foreach ($rss as $contest) { + if (!($contest['start'] instanceof DateTime)) { + log_message('debug',"Invalid Time format for contest: " . $contest['title']); + continue; + } $start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d'))); if ($start >= $nextFriday && $start <= $nextSunday) { @@ -168,6 +177,10 @@ class Contestcalendar extends CI_Controller { $nextMonday = date('Y-m-d', strtotime('next monday', strtotime($today))); foreach ($rss as $contest) { + if (!($contest['start'] instanceof DateTime)) { + log_message('debug',"Invalid Time format for contest: " . $contest['title']); + continue; + } $start = date('Y-m-d', strtotime($contest['start']->format('Y-m-d'))); if ($start >= $nextMonday) {