mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/12627] Add debug.sql_explain parameter
PHPBB3-12627
This commit is contained in:
@@ -75,6 +75,11 @@ abstract class driver implements driver_interface
|
||||
const SUBQUERY_SELECT_TYPE = 4;
|
||||
const SUBQUERY_BUILD = 5;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $debug_sql_explain = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -95,6 +100,14 @@ abstract class driver implements driver_interface
|
||||
$this->one_char = chr(0) . '_';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_sql_explain($value)
|
||||
{
|
||||
$this->debug_sql_explain = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -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) : '';
|
||||
}
|
||||
|
@@ -15,6 +15,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.
|
||||
*
|
||||
|
@@ -65,6 +65,14 @@ class factory implements driver_interface
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_debug_sql_explain($value)
|
||||
{
|
||||
$this->get_driver()->set_debug_sql_explain($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user