Skip to content

Commit fc6e5f7

Browse files
committed
sourceSpecIsNewer: explicit false check on strtotime
Guard against malformed datetime strings (e.g. "0000-00-00 00:00:00") that PHP's strtotime() returns false for. Without the explicit check, false gets loose-compared as 0 and the helper silently returns false, meaning a corrupted source updatedAt would always tolerate the existing destination entry and never trigger drop+recreate. Appwrite itself always emits parseable RFC 3339 timestamps, so this is mainly defensive for non-Appwrite sources (Supabase, NHost, CSV). Flagged by greptile P2.
1 parent 2128f97 commit fc6e5f7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Migration/Destinations/Appwrite.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,16 @@ private function sourceSpecIsNewer(string $sourceUpdatedAt, string $destUpdatedA
493493
if ($sourceUpdatedAt === '' || $destUpdatedAt === '') {
494494
return false;
495495
}
496-
return \strtotime($sourceUpdatedAt) > \strtotime($destUpdatedAt);
496+
$src = \strtotime($sourceUpdatedAt);
497+
$dst = \strtotime($destUpdatedAt);
498+
if ($src === false || $dst === false) {
499+
// Conservative: any unparseable timestamp → don't drop+recreate.
500+
// Matters for non-Appwrite sources that may emit malformed dates
501+
// (e.g. "0000-00-00 00:00:00"); Appwrite itself always emits
502+
// parseable RFC 3339.
503+
return false;
504+
}
505+
return $src > $dst;
497506
}
498507

499508
/**

0 commit comments

Comments
 (0)