From 9e7c18afba576ae3a5196d17d0f0dcd9926d256b Mon Sep 17 00:00:00 2001 From: nat Date: Sun, 1 Sep 2024 14:54:35 -0700 Subject: [PATCH] feat: have sql_get_actor return null when no actor is found --- public/api/v1/database.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/api/v1/database.php b/public/api/v1/database.php index c579daf..0c34489 100644 --- a/public/api/v1/database.php +++ b/public/api/v1/database.php @@ -19,5 +19,8 @@ function sql_fetch_actor($conn, string $preferred_username) { array(':object_id' => $object_id) ); - return $result->fetchArray(SQLITE3_ASSOC); + // fetchArray returns false when there's no array; we're rather have it be + // explicitly null + $actor = $result->fetchArray(SQLITE3_ASSOC); + return $actor !== false ? $actor : null; }