From 58e69d2596ee1ee7c447e0d972e295b78285ff0c Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 3 Jul 2025 08:13:46 -0600 Subject: [PATCH] Fix the user_uuid using database::new() --- resources/classes/database.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/resources/classes/database.php b/resources/classes/database.php index 291e6feb19..dd28a4df08 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -1,4 +1,4 @@ -domain_uuid = $params['domain_uuid']; } - //allow passed user_uuid in the constructor to override the session user_uuid + //set the user_uuid if (isset($params['user_uuid'])) { + //allow passed user_uuid in the constructor to override the session user_uuid $this->user_uuid = $params['user_uuid']; - } else { + } elseif (!empty($_SESSION['user_uuid'])) { //try to determine the current user_uuid using the session - $this->user_uuid = (!empty($_SESSION['user_uuid']) ? $_SESSION['user_uuid'] : null); + $this->user_uuid = $_SESSION['user_uuid']; } } @@ -3280,12 +3281,24 @@ * @see database::connect() */ public static function new(array $params = []) { + + //re-use the database connection if (self::$database === null) { self::$database = new database($params); if (!self::$database->is_connected()) { self::$database->connect(); } } + + //set the user_uuid + if (isset($params['user_uuid'])) { + //allow passed user_uuid in the constructor to override the session user_uuid + self::$database->user_uuid = $params['user_uuid']; + } elseif (!empty($_SESSION['user_uuid'])) { + //try to determine the current user_uuid using the session + self::$database->user_uuid = $_SESSION['user_uuid']; + } + return self::$database; }