1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-29 18:50:25 +02:00

Merge pull request #5266 from senky/ticket/12624

[ticket/12624] Add debug.load_time parameter

* github.com:/phpbb/phpbb:
  [ticket/12624] Add debug.load_time parameter
This commit is contained in:
Tristan Darricau 2018-07-08 18:32:45 +02:00
commit f6301ea85a
17 changed files with 43 additions and 21 deletions

View File

@ -132,6 +132,7 @@ $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'));
$phpbb_container->get('dbal.conn')->set_debug_load_time($phpbb_container->getParameter('debug.load_time'));
require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);

View File

@ -6,6 +6,7 @@ core:
debug:
exceptions: true
load_time: true
sql_explain: true
twig:

View File

@ -4563,7 +4563,7 @@ function phpbb_generate_debug_output(\phpbb\db\driver\driver_interface $db, \php
$debug_info = array();
// Output page creation time
if (defined('PHPBB_DISPLAY_LOAD_TIME'))
if ($phpbb_container->getParameter('debug.load_time'))
{
if (isset($GLOBALS['starttime']))
{

View File

@ -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
*/
@ -103,9 +108,7 @@ abstract class driver implements driver_interface
/**
* {@inheritdoc}
*/
public function set_debug_sql_explain($value)
{
$this->debug_sql_explain = $value;
}
/**

View File

@ -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
*

View File

@ -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}
*/

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -35,6 +35,7 @@ class container_configuration implements ConfigurationInterface
->addDefaultsIfNotSet()
->children()
->booleanNode('exceptions')->defaultValue(false)->end()
->booleanNode('load_time')->defaultValue(false)->end()
->booleanNode('sql_explain')->defaultValue(false)->end()
->end()
->end()

View File

@ -191,7 +191,6 @@ class create_config_file extends \phpbb\install\task_base
}
$config_content .= "\n@define('PHPBB_INSTALLED', true);\n";
$config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n";
if ($environment)
{

View File

@ -18,6 +18,11 @@ class phpbb_mock_container_builder implements ContainerInterface
protected $services = array();
protected $parameters = array();
public function __construct()
{
$this->setParameter('debug.load_time', false);
}
/**
* Sets a service.
*

View File

@ -37,9 +37,6 @@ echo "@define('DEBUG', true);" >> ${PHPBB_CONFIG}
# Change environment to development
sed -i '/^.*PHPBB_ENVIRONMENT.*$/s/production/development/' ${PHPBB_CONFIG}
# Display load time
sed -i '/^.*PHPBB_DISPLAY_LOAD_TIME.*$/s/^\/\/[[:blank:]]*//' ${PHPBB_CONFIG}
# Update the PHP memory limits (enough to allow phpunit tests to run)
sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/7.1/fpm/php.ini