Tentative de régler le bordel

This commit is contained in:
Gauvain Boiché
2020-03-31 15:58:31 +02:00
parent a1864c0414
commit 459b46df7b
345 changed files with 10758 additions and 4066 deletions

View File

@@ -75,6 +75,16 @@ abstract class driver implements driver_interface
const SUBQUERY_SELECT_TYPE = 4;
const SUBQUERY_BUILD = 5;
/**
* @var bool
*/
protected $debug_load_time = false;
/**
* @var bool
*/
protected $debug_sql_explain = false;
/**
* Constructor
*/
@@ -95,6 +105,22 @@ 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}
*/
public function set_debug_sql_explain($value)
{
$this->debug_sql_explain = $value;
}
/**
* {@inheritdoc}
*/
@@ -955,7 +981,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) : '';
}

View File

@@ -15,6 +15,20 @@ 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
*
* @param bool $value
*/
public function set_debug_sql_explain($value);
/**
* Gets the name of the sql layer.
*

View File

@@ -65,6 +65,22 @@ 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}
*/
public function set_debug_sql_explain($value)
{
$this->get_driver()->set_debug_sql_explain($value);
}
/**
* {@inheritdoc}
*/

View File

@@ -151,12 +151,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -172,11 +171,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->sql_time += microtime(true) - $this->curtime;
}
@@ -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);
}

View File

@@ -123,12 +123,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -146,11 +145,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->sql_time += microtime(true) - $this->curtime;
}
@@ -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);
}

View File

@@ -68,6 +68,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
if ($this->db_connect_id && $this->dbname != '')
{
// Disable loading local files on client side
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
@mysqli_query($this->db_connect_id, "SET NAMES 'utf8'");
// enforce strict mode on databases that support it
@@ -173,12 +176,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -193,11 +195,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->sql_time += microtime(true) - $this->curtime;
}
@@ -212,7 +214,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);
}
@@ -373,7 +375,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
{
static $test_prof;
// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
// current detection method, might just switch to see the existence of INFORMATION_SCHEMA.PROFILING
if ($test_prof === null)
{
$test_prof = false;

View File

@@ -246,12 +246,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -428,11 +427,11 @@ class oracle extends \phpbb\db\driver\driver
}
}
if (defined('DEBUG'))
if ($this->debug_sql_explain)
{
$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;
}
@@ -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);
}

View File

@@ -173,12 +173,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -194,11 +193,11 @@ class postgres extends \phpbb\db\driver\driver
$this->sql_error($query);
}
if (defined('DEBUG'))
if ($this->debug_sql_explain)
{
$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;
}
@@ -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);
}

View File

@@ -118,12 +118,11 @@ 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);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
else if ($this->debug_load_time)
{
$this->curtime = microtime(true);
}
@@ -156,11 +155,11 @@ class sqlite3 extends \phpbb\db\driver\driver
}
}
if (defined('DEBUG'))
if ($this->debug_sql_explain)
{
$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;
}
@@ -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);
}