From cd25980da931e904793019d0b5c5d546b84cedc1 Mon Sep 17 00:00:00 2001 From: iglocska Date: Tue, 23 Apr 2024 15:03:22 +0200 Subject: [PATCH] fix: [sql logs] captured when benchmarking is enabled but debug level is < 2 --- app/Lib/Tools/BenchmarkTool.php | 3 --- app/Model/Datasource/Database/MysqlExtended.php | 4 +++- app/Model/Datasource/Database/MysqlObserverExtended.php | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Lib/Tools/BenchmarkTool.php b/app/Lib/Tools/BenchmarkTool.php index 8f741b854..ca2956590 100644 --- a/app/Lib/Tools/BenchmarkTool.php +++ b/app/Lib/Tools/BenchmarkTool.php @@ -15,9 +15,6 @@ class BenchmarkTool /** @var retention */ private $retention = 0; - /** @var start_time */ - public $start_timexxx; - const BENCHMARK_SCOPES = ['user', 'endpoint', 'user_agent']; const BENCHMARK_FIELDS = ['time', 'sql_time', 'sql_queries', 'memory']; const BENCHMARK_UNITS = [ diff --git a/app/Model/Datasource/Database/MysqlExtended.php b/app/Model/Datasource/Database/MysqlExtended.php index 02d486529..32718ed72 100644 --- a/app/Model/Datasource/Database/MysqlExtended.php +++ b/app/Model/Datasource/Database/MysqlExtended.php @@ -152,7 +152,9 @@ class MysqlExtended extends Mysql public function execute($sql, $options = [], $params = []) { $log = $options['log'] ?? $this->fullDebug; - + if (Configure::read('Plugin.Benchmarking_enable')) { + $log = true; + } if ($log) { $t = microtime(true); $this->_result = $this->_execute($sql, $params); diff --git a/app/Model/Datasource/Database/MysqlObserverExtended.php b/app/Model/Datasource/Database/MysqlObserverExtended.php index ecd05af25..1eeb3d465 100644 --- a/app/Model/Datasource/Database/MysqlObserverExtended.php +++ b/app/Model/Datasource/Database/MysqlObserverExtended.php @@ -144,6 +144,9 @@ class MysqlObserverExtended extends Mysql public function execute($sql, $options = [], $params = []) { $log = $options['log'] ?? $this->fullDebug; + if (Configure::read('Plugin.Benchmarking_enable')) { + $log = true; + } $comment = sprintf( '%s%s%s', empty(Configure::read('CurrentUserId')) ? '' : sprintf(