From 139eb17bb729763ab670fb239c77db02e29920f6 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Mon, 18 Jun 2018 20:35:01 +0200 Subject: [ticket/12624] Add debug.load_time parameter PHPBB3-12624 --- phpBB/phpbb/db/driver/driver.php | 13 +++++++++++++ phpBB/phpbb/db/driver/driver_interface.php | 7 +++++++ phpBB/phpbb/db/driver/factory.php | 8 ++++++++ phpBB/phpbb/db/driver/mssql_odbc.php | 4 ++-- phpBB/phpbb/db/driver/mssqlnative.php | 4 ++-- phpBB/phpbb/db/driver/mysql.php | 4 ++-- phpBB/phpbb/db/driver/mysqli.php | 4 ++-- phpBB/phpbb/db/driver/oracle.php | 4 ++-- phpBB/phpbb/db/driver/postgres.php | 4 ++-- phpBB/phpbb/db/driver/sqlite3.php | 4 ++-- 10 files changed, 42 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/db/driver') diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index ab8de73531..93f0a749e5 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -75,6 +75,11 @@ abstract class driver implements driver_interface const SUBQUERY_SELECT_TYPE = 4; const SUBQUERY_BUILD = 5; + /** + * @var bool + */ + protected $debug_load_time = false; + /** * @var bool */ @@ -100,6 +105,14 @@ abstract class driver implements driver_interface $this->one_char = chr(0) . '_'; } + /** + * {@inheritdoc} + */ + public function set_debug_load_time($value) + { + $this->debug_load_time = $value; + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/db/driver/driver_interface.php b/phpBB/phpbb/db/driver/driver_interface.php index 6602ffb4e4..05ff5ef066 100644 --- a/phpBB/phpbb/db/driver/driver_interface.php +++ b/phpBB/phpbb/db/driver/driver_interface.php @@ -15,6 +15,13 @@ namespace phpbb\db\driver; interface driver_interface { + /** + * Set value for load_time debug parameter + * + * @param bool $value + */ + public function set_debug_load_time($value); + /** * Set value for sql_explain debug parameter * diff --git a/phpBB/phpbb/db/driver/factory.php b/phpBB/phpbb/db/driver/factory.php index 122cbcc10d..bb6e7a2682 100644 --- a/phpBB/phpbb/db/driver/factory.php +++ b/phpBB/phpbb/db/driver/factory.php @@ -65,6 +65,14 @@ class factory implements driver_interface $this->driver = $driver; } + /** + * {@inheritdoc} + */ + public function set_debug_load_time($value) + { + $this->get_driver()->set_debug_load_time($value); + } + /** * {@inheritdoc} */ diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php index 58c2863f53..06cdce7a15 100644 --- a/phpBB/phpbb/db/driver/mssql_odbc.php +++ b/phpBB/phpbb/db/driver/mssql_odbc.php @@ -155,7 +155,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -175,7 +175,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index ff37eaf1c2..30ef9d9bc4 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -127,7 +127,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -149,7 +149,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php index 65ec57dc14..8ce70444c2 100644 --- a/phpBB/phpbb/db/driver/mysql.php +++ b/phpBB/phpbb/db/driver/mysql.php @@ -175,7 +175,7 @@ class mysql extends \phpbb\db\driver\mysql_base { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -194,7 +194,7 @@ class mysql extends \phpbb\db\driver\mysql_base { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php index b10abeb6bd..df8b88c315 100644 --- a/phpBB/phpbb/db/driver/mysqli.php +++ b/phpBB/phpbb/db/driver/mysqli.php @@ -177,7 +177,7 @@ class mysqli extends \phpbb\db\driver\mysql_base { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -196,7 +196,7 @@ class mysqli extends \phpbb\db\driver\mysql_base { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php index ab194f7c53..f2a0bb557a 100644 --- a/phpBB/phpbb/db/driver/oracle.php +++ b/phpBB/phpbb/db/driver/oracle.php @@ -250,7 +250,7 @@ class oracle extends \phpbb\db\driver\driver { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -431,7 +431,7 @@ class oracle extends \phpbb\db\driver\driver { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index 2052268921..ed330bc540 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -177,7 +177,7 @@ class postgres extends \phpbb\db\driver\driver { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -197,7 +197,7 @@ class postgres extends \phpbb\db\driver\driver { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php index a1adc97ebf..43906f1b58 100644 --- a/phpBB/phpbb/db/driver/sqlite3.php +++ b/phpBB/phpbb/db/driver/sqlite3.php @@ -122,7 +122,7 @@ class sqlite3 extends \phpbb\db\driver\driver { $this->sql_report('start', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->curtime = microtime(true); } @@ -159,7 +159,7 @@ class sqlite3 extends \phpbb\db\driver\driver { $this->sql_report('stop', $query); } - else if (defined('PHPBB_DISPLAY_LOAD_TIME')) + else if ($this->debug_load_time) { $this->sql_time += microtime(true) - $this->curtime; } -- cgit v1.2.1