From 084a60da013242606a81154e49257ab3ff51713f Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 24 Jun 2008 22:39:18 +0200 Subject: [PATCH 1/1] SQL error MUST NOT happen... so stop the execution of if an SQL error is found. Why ? I've found too many invisible SQL errors during the last few weeks (invisible == not shown in a backtrace because of a page redirection). SQL errors are evil (hum), they should NEVER happen: a query that is allowed to fail can always been rewritten in a way errors are ignored (e.g. INSERT IGNORE). Signed-off-by: Florent Bruneau --- classes/xdb.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/xdb.php b/classes/xdb.php index a9cb068..19786b4 100644 --- a/classes/xdb.php +++ b/classes/xdb.php @@ -76,7 +76,8 @@ class XDB global $globals; if (!XDB::$mysqli && !XDB::connect()) { - return false; + Platal::page()->kill('Impossible de se connecter à la base de données.'); + exit; } if ($globals->debug & DEBUG_BT) { @@ -100,6 +101,16 @@ class XDB XDB::$mysqli->error, $explain); } + + if ($res === false) { + if (strpos($query, 'INSERT') === false && strpos($query, 'UPDATE') === false + && strpos($query, 'REPLACE') === false && strpos($query, 'DELETE') === false) { + Platal::page()->kill('Erreur lors de l\'interrogation de la base de données'); + } else { + Platal::page()->kill('Erreur lors de l\'écriture dans la base de données'); + } + exit; + } return $res; } -- 2.1.4