Fix todo API: PHP warning on missing due_date key corrupted JSON output
Deploy HouseHub / deploy (push) Successful in 1s
Deploy HouseHub / deploy (push) Successful in 1s
Use ?? null before ?: null for optional fields; add ob_start() as safety net. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9ec78ba77e
commit
c3229cbf11
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ob_start();
|
||||||
require_once dirname(__DIR__, 2) . '/includes/auth.php';
|
require_once dirname(__DIR__, 2) . '/includes/auth.php';
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
@@ -111,11 +112,11 @@ if ($action === 'todos') {
|
|||||||
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
|
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
|
||||||
$pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, due_time, priority) VALUES (?,?,?,?,?,?)")
|
$pdo->prepare("INSERT INTO pf_todos (list_id, title, notes, due_date, due_time, priority) VALUES (?,?,?,?,?,?)")
|
||||||
->execute([
|
->execute([
|
||||||
$d['list_id'] ?: null,
|
($d['list_id'] ?? null) ?: null,
|
||||||
$title,
|
$title,
|
||||||
$d['notes'] ?? null,
|
$d['notes'] ?? null,
|
||||||
$d['due_date'] ?: null,
|
($d['due_date'] ?? null) ?: null,
|
||||||
$d['due_time'] ?: null,
|
($d['due_time'] ?? null) ?: null,
|
||||||
$d['priority'] ?? 'none'
|
$d['priority'] ?? 'none'
|
||||||
]);
|
]);
|
||||||
$id = (int)$pdo->lastInsertId();
|
$id = (int)$pdo->lastInsertId();
|
||||||
@@ -147,7 +148,7 @@ if ($action === 'todos') {
|
|||||||
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
|
$title = trim($d['title'] ?? ''); if (!$title) tErr('Titre requis');
|
||||||
// Reset notified_date so cron fires again today if time changed
|
// 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=?")
|
$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]);
|
tOk(['updated' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user