From 37262c24d91796246db5d7562b23925df6b9e39a Mon Sep 17 00:00:00 2001 From: Johannes Schwab Date: Fri, 4 Aug 2017 11:01:29 +0200 Subject: [PATCH] Catch exceptions in PDO constructor --- include/dba.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/dba.php b/include/dba.php index d921167c1d..9b69158e2b 100644 --- a/include/dba.php +++ b/include/dba.php @@ -75,9 +75,11 @@ class dba { if (isset($a->config["system"]["db_charset"])) { $connect .= ";charset=".$a->config["system"]["db_charset"]; } - $this->db = @new PDO($connect, $user, $pass); - if (!$this->db->errorCode()) { + try { + $this->db = @new PDO($connect, $user, $pass); $this->connected = true; + } catch (PDOException $e) { + $this->connected = false; } } elseif (class_exists('mysqli')) { $this->driver = 'mysqli';