From d6f39a341086c50d5272004877efd9bc9ecfea68 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 27 Aug 2024 11:46:18 +0200 Subject: [PATCH] Database: patch error handling to account for exceptions thrown by mysqli_query --- models/Database.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/Database.php b/models/Database.php index 3d5cb4c4..226cd749 100644 --- a/models/Database.php +++ b/models/Database.php @@ -306,9 +306,11 @@ class Database if (defined("DB_LOG_QUERIES") && DB_LOG_QUERIES) $this->logged_queries[] = $db_string; - $return = @mysqli_query($this->connection, $db_string, empty($this->unbuffered) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); - - if (!$return) + try + { + $return = @mysqli_query($this->connection, $db_string, empty($this->unbuffered) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); + } + catch (Exception $e) { $clean_sql = implode("\n", array_map('trim', explode("\n", $db_string))); trigger_error($this->error() . '
' . $clean_sql, E_USER_ERROR);