From 13f7725cf10a60cf3a3e556cae1977d25fbefa4c Mon Sep 17 00:00:00 2001 From: HoeenHero Date: Mon, 4 Aug 2025 10:14:14 -0400 Subject: [PATCH] Set timeout in PDO constructor instead of a seperate query --- lib/ntbb-database.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ntbb-database.lib.php b/lib/ntbb-database.lib.php index f1b0a1d2a..52739453f 100644 --- a/lib/ntbb-database.lib.php +++ b/lib/ntbb-database.lib.php @@ -25,13 +25,12 @@ class PSDatabase { if (!$this->db) { try { $this->db = new PDO( - "mysql:dbname={$this->database};host={$this->server};charset={$this->charset}", + "mysql:dbname={$this->database};host={$this->server};charset={$this->charset};wait_timeout=7200", $this->username, $this->password, [PDO::ATTR_PERSISTENT => true] ); $this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - $this->db->exec("SET SESSION wait_timeout = 7200"); } catch (PDOException $e) { if (strpos($e->getMessage(), '1040') !== false || strpos($e->getMessage(), 'Too many connections') !== false) { http_response_code(503);