From 9ac7758e875f87bbafac3d2ff0a241495bf2c2ff Mon Sep 17 00:00:00 2001 From: Jonathan Flueren <11487762+JonOfUs@users.noreply.github.com> Date: Thu, 12 Aug 2021 15:27:58 +0200 Subject: [PATCH] Correct empty timestamp check in createDateTimeFromTimestamp createDateTimeFromTimestamp interpreted 0 as timestamp as a mistake while 0 is a valid timestamp. The fix checks if timestamp is null (not defined/initialized), so that 0 is treated as a correct timestamp. --- lib/Controller/EpisodeActionController.php | 2 +- lib/Controller/SubscriptionChangeController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index 8f17220..ce92782 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -98,7 +98,7 @@ class EpisodeActionController extends Controller { * @return DateTime */ private function createDateTimeFromTimestamp(?int $since): DateTime { - return ($since) + return ($since !== null) ? (new \DateTime)->setTimestamp($since) : (new \DateTime('-1 week')); } diff --git a/lib/Controller/SubscriptionChangeController.php b/lib/Controller/SubscriptionChangeController.php index 6be166f..6d4b38e 100644 --- a/lib/Controller/SubscriptionChangeController.php +++ b/lib/Controller/SubscriptionChangeController.php @@ -73,7 +73,7 @@ class SubscriptionChangeController extends Controller { * @return DateTime */ private function createDateTimeFromTimestamp(?int $since): DateTime { - return ($since) + return ($since !== null) ? (new \DateTime)->setTimestamp($since) : (new \DateTime('-1 week')); }