aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/config/development/config.yml1
-rw-r--r--phpBB/includes/functions.php4
-rw-r--r--phpBB/phpbb/db/driver/driver.php15
-rw-r--r--phpBB/phpbb/db/driver/driver_interface.php7
-rw-r--r--phpBB/phpbb/db/driver/factory.php8
-rw-r--r--phpBB/phpbb/db/driver/mssql_odbc.php7
-rw-r--r--phpBB/phpbb/db/driver/mssqlnative.php7
-rw-r--r--phpBB/phpbb/db/driver/mysql.php7
-rw-r--r--phpBB/phpbb/db/driver/mysqli.php7
-rw-r--r--phpBB/phpbb/db/driver/oracle.php7
-rw-r--r--phpBB/phpbb/db/driver/postgres.php7
-rw-r--r--phpBB/phpbb/db/driver/sqlite3.php7
-rw-r--r--phpBB/phpbb/di/extension/container_configuration.php1
14 files changed, 57 insertions, 30 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 172503f078..a9a5139995 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -132,6 +132,8 @@ catch (InvalidArgumentException $e)
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
+$phpbb_container->get('dbal.conn')->set_debug_sql_explain($phpbb_container->getParameter('debug.sql_explain'));
+
require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
register_compatibility_globals();
diff --git a/phpBB/config/development/config.yml b/phpBB/config/development/config.yml
index f39eb52e73..44517cf5e0 100644
--- a/phpBB/config/development/config.yml
+++ b/phpBB/config/development/config.yml
@@ -6,6 +6,7 @@ core:
debug:
exceptions: true
+ sql_explain: true
twig:
debug: true
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 44c51eb1ad..6046bf1d71 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -4646,6 +4646,8 @@ function phpbb_check_and_display_sql_report(\phpbb\request\request_interface $re
*/
function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
{
+ global $phpbb_container;
+
$debug_info = array();
// Output page creation time
@@ -4677,7 +4679,7 @@ function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \php
$debug_info[] = 'Load: ' . $user->load;
}
- if ($auth->acl_get('a_'))
+ if ($auth->acl_get('a_') && $phpbb_container->getParameter('debug.sql_explain'))
{
$debug_info[] = '<a href="' . build_url() . '&amp;explain=1">SQL Explain</a>';
}
diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php
index a36ce8c0d7..ab8de73531 100644
--- a/phpBB/phpbb/db/driver/driver.php
+++ b/phpBB/phpbb/db/driver/driver.php
@@ -76,6 +76,11 @@ abstract class driver implements driver_interface
const SUBQUERY_BUILD = 5;
/**
+ * @var bool
+ */
+ protected $debug_sql_explain = false;
+
+ /**
* Constructor
*/
function __construct()
@@ -98,6 +103,14 @@ abstract class driver implements driver_interface
/**
* {@inheritdoc}
*/
+ public function set_debug_sql_explain($value)
+ {
+ $this->debug_sql_explain = $value;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function get_sql_layer()
{
return $this->sql_layer;
@@ -955,7 +968,7 @@ abstract class driver implements driver_interface
// Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled
// The DEBUG constant is for development only!
- if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG'))
+ if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || $this->debug_sql_explain)
{
$message .= ($sql) ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';
}
diff --git a/phpBB/phpbb/db/driver/driver_interface.php b/phpBB/phpbb/db/driver/driver_interface.php
index 8b487c5d42..6602ffb4e4 100644
--- a/phpBB/phpbb/db/driver/driver_interface.php
+++ b/phpBB/phpbb/db/driver/driver_interface.php
@@ -16,6 +16,13 @@ namespace phpbb\db\driver;
interface driver_interface
{
/**
+ * Set value for sql_explain debug parameter
+ *
+ * @param bool $value
+ */
+ public function set_debug_sql_explain($value);
+
+ /**
* Gets the name of the sql layer.
*
* @return string
diff --git a/phpBB/phpbb/db/driver/factory.php b/phpBB/phpbb/db/driver/factory.php
index fb3a826254..122cbcc10d 100644
--- a/phpBB/phpbb/db/driver/factory.php
+++ b/phpBB/phpbb/db/driver/factory.php
@@ -68,6 +68,14 @@ class factory implements driver_interface
/**
* {@inheritdoc}
*/
+ public function set_debug_sql_explain($value)
+ {
+ $this->get_driver()->set_debug_sql_explain($value);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function get_sql_layer()
{
return $this->get_driver()->get_sql_layer();
diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php
index 9d9ad603e0..58c2863f53 100644
--- a/phpBB/phpbb/db/driver/mssql_odbc.php
+++ b/phpBB/phpbb/db/driver/mssql_odbc.php
@@ -151,8 +151,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -172,7 +171,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
$this->sql_error($query);
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -196,7 +195,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php
index a4dcac5966..ff37eaf1c2 100644
--- a/phpBB/phpbb/db/driver/mssqlnative.php
+++ b/phpBB/phpbb/db/driver/mssqlnative.php
@@ -123,8 +123,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -146,7 +145,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
// reset options for next query
$this->query_options = array();
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -170,7 +169,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php
index 5eabe0f9ef..65ec57dc14 100644
--- a/phpBB/phpbb/db/driver/mysql.php
+++ b/phpBB/phpbb/db/driver/mysql.php
@@ -171,8 +171,7 @@ class mysql extends \phpbb\db\driver\mysql_base
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -191,7 +190,7 @@ class mysql extends \phpbb\db\driver\mysql_base
$this->sql_error($query);
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -215,7 +214,7 @@ class mysql extends \phpbb\db\driver\mysql_base
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php
index 57962fdf20..b10abeb6bd 100644
--- a/phpBB/phpbb/db/driver/mysqli.php
+++ b/phpBB/phpbb/db/driver/mysqli.php
@@ -173,8 +173,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -193,7 +192,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
$this->sql_error($query);
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -212,7 +211,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php
index 5fd14709f8..ab194f7c53 100644
--- a/phpBB/phpbb/db/driver/oracle.php
+++ b/phpBB/phpbb/db/driver/oracle.php
@@ -246,8 +246,7 @@ class oracle extends \phpbb\db\driver\driver
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -428,7 +427,7 @@ class oracle extends \phpbb\db\driver\driver
}
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -452,7 +451,7 @@ class oracle extends \phpbb\db\driver\driver
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php
index 44476612c3..2052268921 100644
--- a/phpBB/phpbb/db/driver/postgres.php
+++ b/phpBB/phpbb/db/driver/postgres.php
@@ -173,8 +173,7 @@ class postgres extends \phpbb\db\driver\driver
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -194,7 +193,7 @@ class postgres extends \phpbb\db\driver\driver
$this->sql_error($query);
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -218,7 +217,7 @@ class postgres extends \phpbb\db\driver\driver
$this->open_queries[(int) $this->query_result] = $this->query_result;
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php
index 0508500c52..a1adc97ebf 100644
--- a/phpBB/phpbb/db/driver/sqlite3.php
+++ b/phpBB/phpbb/db/driver/sqlite3.php
@@ -118,8 +118,7 @@ class sqlite3 extends \phpbb\db\driver\driver
{
global $cache;
- // EXPLAIN only in extra debug mode
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('start', $query);
}
@@ -156,7 +155,7 @@ class sqlite3 extends \phpbb\db\driver\driver
}
}
- if (defined('DEBUG'))
+ if ($this->debug_sql_explain)
{
$this->sql_report('stop', $query);
}
@@ -175,7 +174,7 @@ class sqlite3 extends \phpbb\db\driver\driver
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
}
- else if (defined('DEBUG'))
+ else if ($this->debug_sql_explain)
{
$this->sql_report('fromcache', $query);
}
diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php
index 4585d6509e..7d1a1abe5e 100644
--- a/phpBB/phpbb/di/extension/container_configuration.php
+++ b/phpBB/phpbb/di/extension/container_configuration.php
@@ -35,6 +35,7 @@ class container_configuration implements ConfigurationInterface
->addDefaultsIfNotSet()
->children()
->booleanNode('exceptions')->defaultValue(false)->end()
+ ->booleanNode('sql_explain')->defaultValue(false)->end()
->end()
->end()
->arrayNode('twig')