1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-01 18:47:20 +01:00

Rendering $debug: Copy to $_debug so that $debug doesn't become broken if we want to generate more than one file in a request

This commit is contained in:
Michael Foster 2013-08-30 09:00:47 +10:00
parent 29780f8e53
commit c3e528378a

View File

@ -45,21 +45,23 @@ function Element($templateFile, array $options) {
}
if (isset($options['body']) && $config['debug']) {
$_debug = $debug;
if (isset($debug['start'])) {
$debug['time']['total'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
$debug['time']['init'] = '~' . round(($debug['start_debug'] - $debug['start']) * 1000, 2) . 'ms';
unset($debug['start']);
unset($debug['start_debug']);
$_debug['time']['total'] = '~' . round((microtime(true) - $_debug['start']) * 1000, 2) . 'ms';
$_debug['time']['init'] = '~' . round(($_debug['start_debug'] - $_debug['start']) * 1000, 2) . 'ms';
unset($_debug['start']);
unset($_debug['start_debug']);
}
if ($config['try_smarter'] && isset($build_pages) && !empty($build_pages))
$debug['build_pages'] = $build_pages;
$debug['included'] = get_included_files();
$debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
$debug['time']['db_queries'] = '~' . round($debug['time']['db_queries'] * 1000, 2) . 'ms';
$debug['time']['exec'] = '~' . round($debug['time']['exec'] * 1000, 2) . 'ms';
$_debug['build_pages'] = $build_pages;
$_debug['included'] = get_included_files();
$_debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
$_debug['time']['db_queries'] = '~' . round($_debug['time']['db_queries'] * 1000, 2) . 'ms';
$_debug['time']['exec'] = '~' . round($_debug['time']['exec'] * 1000, 2) . 'ms';
$options['body'] .=
'<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' .
str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) .
str_replace("\n", '<br/>', utf8tohtml(print_r($_debug, true))) .
'</pre>';
}