From c3e528378a9314fd5d4a7575c31f8fda50c998d7 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Fri, 30 Aug 2013 09:00:47 +1000 Subject: [PATCH] Rendering $debug: Copy to $_debug so that $debug doesn't become broken if we want to generate more than one file in a request --- inc/template.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/inc/template.php b/inc/template.php index d9e1c386..378f36d0 100644 --- a/inc/template.php +++ b/inc/template.php @@ -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'] .= '

Debug

' .
-				str_replace("\n", '
', utf8tohtml(print_r($debug, true))) . + str_replace("\n", '
', utf8tohtml(print_r($_debug, true))) . '
'; }