From bd120608d709be9226b5255cf3d3b7ba13d44236 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Mon, 10 Aug 2026 20:07:59 -0500 Subject: [PATCH] syncUserLogs: delegate to backfillUserLogs when user has no rows --- functions.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/functions.php b/functions.php index 6c9811f..abb86d8 100644 --- a/functions.php +++ b/functions.php @@ -102,6 +102,18 @@ function syncUserLogs($user) { $pdo = getDatabaseConnection(); + $stmt = $pdo->prepare('SELECT COUNT(*) FROM vault WHERE user = :user'); + $stmt->bindValue(':user', $user); + $stmt->execute(); + $userRowCount = (int)$stmt->fetchColumn(); + + // If the user has zero rows (not the global dbNew, but per-user empty), + // delegate to backfillUserLogs which walks the full prev chain. + if ($userRowCount === 0) { + backfillUserLogs($user); + return; + } + $stmt = $pdo->prepare('SELECT MAX(timestamp) AS max_ts FROM vault WHERE user = :user'); $stmt->bindValue(':user', $user); $stmt->execute();