From d3f7098ecc6effc82dbf26b4ef44520ca4e29476 Mon Sep 17 00:00:00 2001 From: singhharsh1708 Date: Mon, 16 Nov 2026 04:00:10 +0530 Subject: [PATCH] fix: event status for a recording event formats a null end time --- tests/php/test_status_open_event_end.php | 77 ++++++++++++++++++++++++ web/ajax/status.php | 4 +- 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 tests/php/test_status_open_event_end.php diff --git a/tests/php/test_status_open_event_end.php b/tests/php/test_status_open_event_end.php new file mode 100644 index 0000000000..4e5627c43a --- /dev/null +++ b/tests/php/test_status_open_event_end.php @@ -0,0 +1,77 @@ + 7, 'MonitorId' => 1, 'StartDateTime' => '2026-11-16 10:00:00', 'EndDateTime' => null); + } + function dbFetchAll($sql, $col = null, $params = array()) { return array(dbFetchOne($sql)); } + function ajaxResponse($data = array()) { $GLOBALS['response'] = $data; throw new StopRequest('ok'); } + function ajaxError($m) { throw new StopRequest($m); } + + $entity = $argv[1]; + $_REQUEST = array('entity' => $entity, 'id' => '7'); + try { + include __DIR__.'/../../web/ajax/status.php'; + } catch (StopRequest $e) { + } + $row = ($entity == 'event') ? $GLOBALS['response']['event'] : $GLOBALS['response']['events'][0]; + $got = $row['EndDateTimeFormatted']; + if ($got === '' and !$deprecations) { + echo "ok - $entity: open event has an empty formatted end time\n"; + } else { + $failures++; + echo "FAIL - $entity: got ".var_export($got, true).' '.implode('; ', $deprecations)."\n"; + } + if ($row['StartDateTimeFormatted'] !== '2026-11-16 10:00:00') { + $failures++; + echo "FAIL - $entity: start time ".var_export($row['StartDateTimeFormatted'], true)."\n"; + } + exit($failures ? 1 : 0); +} diff --git a/web/ajax/status.php b/web/ajax/status.php index 5f6005f6a3..a2f840b2b1 100644 --- a/web/ajax/status.php +++ b/web/ajax/status.php @@ -137,7 +137,7 @@ $statusData = array( 'EndDateTime' => true, 'EndDateTimeFormatted' => array('postFunction'=>function($row){ global $dateTimeFormatter; - return $dateTimeFormatter->format(strtotime($row['EndDateTime'])); + return empty($row['EndDateTime']) ? '' : $dateTimeFormatter->format(strtotime($row['EndDateTime'])); }), 'Width' => true, 'Height' => true, @@ -171,7 +171,7 @@ $statusData = array( 'EndDateTime' => true, 'EndDateTimeFormatted' => array('postFunction'=>function($row){ global $dateTimeFormatter; - return $dateTimeFormatter->format(strtotime($row['EndDateTime'])); + return empty($row['EndDateTime']) ? '' : $dateTimeFormatter->format(strtotime($row['EndDateTime'])); }), 'Width' => true, 'Height' => true,