diff --git a/misuzu.php b/misuzu.php index d252576d..2f0a10c2 100644 --- a/misuzu.php +++ b/misuzu.php @@ -246,6 +246,7 @@ MIG; tpl_add_function('startup_time', false, function (float $time = MSZ_STARTUP) { return microtime(true) - $time; }); + tpl_add_function('sql_query_count', false, [Database::class, 'queryCount']); tpl_add_path(__DIR__ . '/templates'); diff --git a/src/tpl.php b/src/tpl.php index 40cad2e5..ee05daf5 100644 --- a/src/tpl.php +++ b/src/tpl.php @@ -1,5 +1,4 @@ isDebug()) { - tpl_var('query_count', Database::queryCount()); - } - $path = tpl_sanitise_path($path); if (count($vars)) { @@ -80,5 +73,5 @@ function tpl_render(string $path, array $vars = []): string define('MSZ_TPL_RENDER', microtime(true)); } - return $twig->render($path, $GLOBALS[MSZ_TPL_VARS_STORE]); + return Twig::instance()->render($path, $GLOBALS[MSZ_TPL_VARS_STORE]); } diff --git a/templates/master.twig b/templates/master.twig index 01649f38..102dd411 100644 --- a/templates/master.twig +++ b/templates/master.twig @@ -46,8 +46,8 @@ ''|date('Y') }} / {{ ('https://github.com/flashwave/misuzu/tree/' ~ git_branch())|html_link(git_branch(), 'footer__link') }} # {{ ('https://github.com/flashwave/misuzu/commit/' ~ git_commit_hash(true))|html_link(git_commit_hash(), 'footer__link') }} - {% if query_count is defined %} - / SQL Queries: {{ query_count|number_format }} + {% if constant('MSZ_DEBUG') or current_user.user_id|default(0) == 1 %} + / SQL Queries: {{ sql_query_count()|number_format }} / Took: {{ startup_time()|number_format(5) }} seconds / Render: {{ startup_time(constant('MSZ_TPL_RENDER'))|number_format(5) }} seconds {% endif %}