From bc383fa3ec009a1c2cd42de0ecd3ad0ed9bf5054 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Mon, 28 Jul 2025 10:33:14 +0530 Subject: [PATCH] Add safety check for empty header --- src/Appwrite/Platform/Workers/Functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index bf80f94942..c5d1c7a976 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -407,10 +407,12 @@ class Functions extends Action $headers['x-appwrite-continent-code'] = ''; $headers['x-appwrite-continent-eu'] = 'false'; $scheduledAt = $headers['x-appwrite-scheduled-at'] ?? ''; - $executedAt = new \DateTime(); - $headers['x-appwrite-executed-at'] = $executedAt->format('Y-m-d\TH:i:s.v\Z'); - $delay = $executedAt->getTimestamp() - (new \DateTime($scheduledAt))->getTimestamp(); - $headers['x-appwrite-execution-delay'] = (string)floor($delay); + if (!empty($scheduledAt)) { + $executedAt = new \DateTime(); + $headers['x-appwrite-executed-at'] = $executedAt->format('Y-m-d\TH:i:s.v\Z'); + $delay = $executedAt->getTimestamp() - (new \DateTime($scheduledAt))->getTimestamp(); + $headers['x-appwrite-execution-delay'] = (string)floor(max(0, $delay)); + } /** Create execution or update execution status */ $execution = $dbForProject->getDocument('executions', $executionId ?? '');