From 5944ddf72261eea5546e537eeea07c967e9bd4c2 Mon Sep 17 00:00:00 2001 From: magges Date: Sat, 11 Jul 2026 23:12:04 +0000 Subject: [PATCH] Fix WebUI: podman_parse_time() rejected int timestamps from list endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found by exercising the AJAX endpoints directly against a real running podman service (php -d display_errors=1 -r '...containers.php...') — containers.php's list action crashed with an uncaught TypeError the moment a real container existed. podman's libpod API is inconsistent about container/volume timestamp encoding: inspect-style endpoints return RFC3339 strings, but list-style endpoints (containers/json, volumes/json) return raw Unix-epoch integers for the same logical field. podman_parse_time() only accepted ?string, so any list call with a real container blew up outright rather than merely mis-rendering. Widened it to string|int|null and handle both. Verified: containers.php's list action now returns correct JSON for real running/exited containers, including their createdAt timestamps. Co-Authored-By: Claude Sonnet 5 --- webui/plugins/podman/include/helpers.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/webui/plugins/podman/include/helpers.php b/webui/plugins/podman/include/helpers.php index 0a48cb3..e93a8e4 100644 --- a/webui/plugins/podman/include/helpers.php +++ b/webui/plugins/podman/include/helpers.php @@ -42,13 +42,25 @@ function podman_format_duration(int $seconds): string return "{$minutes}m"; } -/** Converts a libpod RFC3339 timestamp (as found in inspect output) to a Unix timestamp, or null if unparsable. */ -function podman_parse_time(?string $rfc3339): ?int +/** + * Converts a libpod timestamp to a Unix timestamp, or null if unparsable. + * Accepts both the RFC3339 strings `inspect`-style endpoints return and + * the raw Unix-epoch integers `list`-style endpoints return for the same + * logical field (e.g. containers/json's StartedAt/Created vs. inspect's) + * — verified live against a real podman system service, not just docs. + */ +function podman_parse_time(string|int|null $value): ?int { - if ($rfc3339 === null || $rfc3339 === '' || str_starts_with($rfc3339, '0001-01-01')) { + if ($value === null || $value === '') { return null; } - $ts = strtotime($rfc3339); + if (is_int($value)) { + return $value > 0 ? $value : null; + } + if (str_starts_with($value, '0001-01-01')) { + return null; + } + $ts = strtotime($value); return $ts === false ? null : $ts; }