From f2b8c9c5e6d4a6e6c13302611a999d60fb37b327 Mon Sep 17 00:00:00 2001 From: Damien Rochat Date: Wed, 16 Sep 2026 14:35:53 +0200 Subject: [PATCH] fix(api): report a missing PDO SQLite driver with a clear message On bare Windows PHP installs the pdo_sqlite extension is often disabled; wrap the PDO connection so the failure surfaces as an actionable error instead of a bare driver exception. --- api/bugs/db.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/bugs/db.php b/api/bugs/db.php index f536642..576b430 100644 --- a/api/bugs/db.php +++ b/api/bugs/db.php @@ -52,7 +52,18 @@ function fws_bugs_db(): PDO mkdir($dir, 0775, true); } - $pdo = new PDO('sqlite:' . $dir . '/fws_bugs.sqlite'); + try { + $pdo = new PDO('sqlite:' . $dir . '/fws_bugs.sqlite'); + } catch (Throwable $e) { + /* Driver PDO SQLite absent (cas fréquent : WAMP/XAMPP où pdo_sqlite + et sqlite3 sont à activer dans php.ini). Message clair au lieu d'un + crash avec stack trace. */ + throw new RuntimeException( + 'Extension PDO SQLite indisponible : activez "extension=pdo_sqlite" et "extension=sqlite3" dans php.ini.', + 0, + $e + ); + } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);