[ticket/12624] Add debug.load_time parameter

PHPBB3-12624
This commit is contained in:
Jakub Senko 2018-06-18 20:35:01 +02:00
parent 1d0046437b
commit fcc3dd996d
No known key found for this signature in database
GPG key ID: 6A7C328CD66EC21E
17 changed files with 54 additions and 19 deletions

View file

@ -131,6 +131,8 @@ catch (InvalidArgumentException $e)
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->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_load_time($phpbb_container->getParameter('debug.load_time'));
require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
register_compatibility_globals(); register_compatibility_globals();

View file

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

View file

@ -4532,10 +4532,12 @@ 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) 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(); $debug_info = array();
// Output page creation time // Output page creation time
if (defined('PHPBB_DISPLAY_LOAD_TIME')) if ($phpbb_container->getParameter('debug.load_time'))
{ {
if (isset($GLOBALS['starttime'])) if (isset($GLOBALS['starttime']))
{ {

View file

@ -75,6 +75,11 @@ abstract class driver implements driver_interface
const SUBQUERY_SELECT_TYPE = 4; const SUBQUERY_SELECT_TYPE = 4;
const SUBQUERY_BUILD = 5; const SUBQUERY_BUILD = 5;
/**
* @var bool
*/
protected $debug_load_time = false;
/** /**
* Constructor * Constructor
*/ */
@ -95,6 +100,14 @@ abstract class driver implements driver_interface
$this->one_char = chr(0) . '_'; $this->one_char = chr(0) . '_';
} }
/**
* {@inheritdoc}
*/
public function set_debug_load_time($value)
{
$this->debug_load_time = $value;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View file

@ -15,6 +15,13 @@ namespace phpbb\db\driver;
interface driver_interface interface driver_interface
{ {
/**
* Set value for load_time debug parameter
*
* @param bool $value
*/
public function set_debug_load_time($value);
/** /**
* Gets the name of the sql layer. * Gets the name of the sql layer.
* *

View file

@ -65,6 +65,14 @@ class factory implements driver_interface
$this->driver = $driver; $this->driver = $driver;
} }
/**
* {@inheritdoc}
*/
public function set_debug_load_time($value)
{
$this->get_driver()->set_debug_load_time($value);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View file

@ -156,7 +156,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -176,7 +176,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -128,7 +128,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -150,7 +150,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -176,7 +176,7 @@ class mysql extends \phpbb\db\driver\mysql_base
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -195,7 +195,7 @@ class mysql extends \phpbb\db\driver\mysql_base
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -178,7 +178,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -197,7 +197,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -251,7 +251,7 @@ class oracle extends \phpbb\db\driver\driver
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -432,7 +432,7 @@ class oracle extends \phpbb\db\driver\driver
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -178,7 +178,7 @@ class postgres extends \phpbb\db\driver\driver
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -198,7 +198,7 @@ class postgres extends \phpbb\db\driver\driver
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

@ -123,7 +123,7 @@ class sqlite3 extends \phpbb\db\driver\driver
{ {
$this->sql_report('start', $query); $this->sql_report('start', $query);
} }
else if (defined('PHPBB_DISPLAY_LOAD_TIME')) else if ($this->debug_load_time)
{ {
$this->curtime = microtime(true); $this->curtime = microtime(true);
} }
@ -160,7 +160,7 @@ class sqlite3 extends \phpbb\db\driver\driver
{ {
$this->sql_report('stop', $query); $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; $this->sql_time += microtime(true) - $this->curtime;
} }

View file

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

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 .= "\n@define('PHPBB_INSTALLED', true);\n";
$config_content .= "// @define('PHPBB_DISPLAY_LOAD_TIME', true);\n";
if ($environment) if ($environment)
{ {

View file

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

View file

@ -37,9 +37,6 @@ echo "@define('DEBUG', true);" >> ${PHPBB_CONFIG}
# Change environment to development # Change environment to development
sed -i '/^.*PHPBB_ENVIRONMENT.*$/s/production/development/' ${PHPBB_CONFIG} 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) # 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 sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/7.1/fpm/php.ini