From ba1dc820eba5c995e707e9fc727ead373a0fc007 Mon Sep 17 00:00:00 2001 From: frytimo Date: Thu, 23 Jan 2025 16:44:36 -0400 Subject: [PATCH] suppress access on null php notice in new is_connected method (#7228) --- resources/classes/database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/classes/database.php b/resources/classes/database.php index 71f12c51ca..37d6bd0f0d 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -2948,7 +2948,7 @@ return $this->message; } //save method - /** + /** * Ensure the database is still connected and active. *

NOTE:
* There is no method in PDO that can reliably detect if the connection is active. Therefor, a lightweight @@ -2957,7 +2957,8 @@ */ public function is_connected(): bool { try { - $stmt = $this->db->query('SELECT 1'); + $stmt = false; + if ($this->db !== null) $stmt = $this->db->query('SELECT 1'); return $stmt !== false; } catch (PDOException $ex) { //database is not connected