From 9fef84bffe63eb7bf0fcf68811873393164cb543 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 11 Aug 2023 06:39:50 +0200 Subject: [PATCH] Fix debugBar mysql logs (Thanks @gpedro) --- system/libs/pot/OTS.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/system/libs/pot/OTS.php b/system/libs/pot/OTS.php index bfcfc7b5..9c988210 100644 --- a/system/libs/pot/OTS.php +++ b/system/libs/pot/OTS.php @@ -370,11 +370,14 @@ class POT throw new RuntimeException('Please install PHP pdo extension. MyAAC will not work without it.'); } - $this->db = new OTS_DB_MySQL($params); - - global $debugBar; - $pdo = new DebugBar\DataCollector\PDO\TraceablePDO($this->db); - $debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo)); + global $debugBar; + if (isset($debugBar)) { + $this->db = new DebugBar\DataCollector\PDO\TraceablePDO(new OTS_DB_MySQL($params)); + $debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($this->db)); + } + else { + $this->db = new OTS_DB_MySQL($params); + } $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }