From c3229cbf1177f09bf7ca336f5b5ef882407c41c9 Mon Sep 17 00:00:00 2001 From: perco Date: Tue, 12 May 2026 15:42:52 +0200 Subject: [PATCH] Fix todo API: PHP warning on missing due_date key corrupted JSON output Use ?? null before ?: null for optional fields; add ob_start() as safety net. Co-Authored-By: Claude Sonnet 4.6 --- modules/todo/api.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/todo/api.php b/modules/todo/api.php index 8c8cb7e..c92d4ea 100644 --- a/modules/todo/api.php +++ b/modules/todo/api.php @@ -1,4 +1,5 @@ prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, due_time, priority) VALUES (?,?,?,?,?,?)") ->execute([ - $d['list_id'] ?: null, + ($d['list_id'] ?? null) ?: null, $title, $d['notes'] ?? null, - $d['due_date'] ?: null, - $d['due_time'] ?: null, + ($d['due_date'] ?? null) ?: null, + ($d['due_time'] ?? null) ?: null, $d['priority'] ?? 'none' ]); $id = (int)$pdo->lastInsertId(); @@ -147,7 +148,7 @@ if ($action === 'todos') { $title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis'); // Reset notified_date so cron fires again today if time changed $pdo->prepare("UPDATE pf_todos SET list_id=?, title=?, notes=?, due_date=?, due_time=?, priority=?, notified_date=NULL, updated_at=NOW() WHERE id=?") - ->execute([$d['list_id'] ?: null, $title, $d['notes'] ?? null, $d['due_date'] ?: null, $d['due_time'] ?: null, $d['priority'] ?? 'none', $id]); + ->execute([($d['list_id'] ?? null) ?: null, $title, $d['notes'] ?? null, ($d['due_date'] ?? null) ?: null, ($d['due_time'] ?? null) ?: null, $d['priority'] ?? 'none', $id]); tOk(['updated' => true]); }