diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 393fe6edb7..96c2c4132e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5030,16 +5030,24 @@ function page_header($page_title = '', $display_online_list = false, $item_id = } /** -* Set the DEBUG_OUTPUT template var +* Check and display the SQL report if requested. */ -function display_debug_output() +function phpbb_check_and_display_sql_report() { - global $starttime, $template, $db, $config, $auth, $user, $request; + global $request, $auth, $db; if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG') && method_exists($db, 'sql_report')) { $db->sql_report('display'); } +} + +/** +* Set the DEBUG_OUTPUT template var +*/ +function phpbb_generate_debug_output() +{ + global $starttime, $db, $config, $auth, $user; $debug_info = array(); @@ -5052,16 +5060,14 @@ function display_debug_output() $debug_info[] = sprintf('Time : %.3fs', $totaltime); $debug_info[] = $db->sql_num_queries() . ' Queries'; - if ($auth->acl_get('a_')) + if (function_exists('memory_get_peak_usage')) { - if (function_exists('memory_get_peak_usage')) + $memory_usage = memory_get_peak_usage(); + if ($memory_usage) { - if ($memory_usage = memory_get_peak_usage()) - { - $memory_usage = get_formatted_filesize($memory_usage); + $memory_usage = get_formatted_filesize($memory_usage); - $debug_info[] = 'Peak Memory Usage: ' . $memory_usage; - } + $debug_info[] = 'Peak Memory Usage: ' . $memory_usage; } } } @@ -5077,13 +5083,11 @@ function display_debug_output() if ($auth->acl_get('a_')) { - $debug_info[] = 'Explain'; + $debug_info[] = 'SQL Explain'; } } - $template->assign_vars(array( - 'DEBUG_OUTPUT' => implode(' | ', $debug_info), - )); + return implode(' | ', $debug_info); } /** @@ -5118,9 +5122,10 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = return; } - display_debug_output(); + phpbb_check_and_display_sql_report(); $template->assign_vars(array( + 'DEBUG_OUTPUT' => phpbb_generate_debug_output(), 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'), diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 86eaf856de..037749f7e9 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -146,9 +146,10 @@ function adm_page_footer($copyright_html = true) return; } - display_debug_output(); + phpbb_check_and_display_sql_report(); $template->assign_vars(array( + 'DEBUG_OUTPUT' => phpbb_generate_debug_output(), 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Limited'),