From b4ee37a403aa5970304b447b31a747e47f9efb18 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 22 Sep 2007 00:46:12 +0200 Subject: [PATCH] SQL Backtrace also contains the queries executed *during* smarty execution Signed-off-by: Florent Bruneau --- classes/platalpage.php | 18 ++++++++++-------- include/notifs.inc.php | 4 ++-- templates/skin/common.backtrace.tpl | 12 +++++++++++- templates/skin/common.devel.tpl | 13 +------------ 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/classes/platalpage.php b/classes/platalpage.php index 950f73e..f89f279 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -120,8 +120,8 @@ abstract class PlatalPage extends Smarty $this->assign('simple', true); case SKINNED: - $this->register_modifier('escape_html', 'escape_html'); - $this->default_modifiers = Array('@escape_html'); + $this->register_modifier('escape_html', 'escape_html'); + $this->default_modifiers = Array('@escape_html'); } $this->register_outputfilter('hide_emails'); $this->addJsLink('wiki.js'); @@ -136,11 +136,6 @@ abstract class PlatalPage extends Smarty exit; } - if ($globals->debug & DEBUG_BT) { - PlBacktrace::clean(); - $this->assign_by_ref('backtraces', PlBacktrace::$bt); - } - $this->assign('validate', true); if (!($globals->debug & DEBUG_SMARTY)) { error_reporting(0); @@ -148,8 +143,15 @@ abstract class PlatalPage extends Smarty $result = $this->fetch($skin); $ttime = sprintf('Temps total: %.02fs - Mémoire totale : %dKo
', microtime(true) - $TIME_BEGIN , memory_get_peak_usage(true) / 1024); - $replc = "VALIDATION HTML INACTIVE
"; + if ($globals->debug & DEBUG_BT) { + PlBacktrace::clean(); + $this->assign_by_ref('backtraces', PlBacktrace::$bt); + $result = str_replace('@@BACKTRACE@@', $this->fetch('skin/common.backtrace.tpl'), $result); + } else { + $result = str_replace('@@BACKTRACE@@', '', $result); + } + $replc = "VALIDATION HTML INACTIVE
"; if ($globals->debug & DEBUG_VALID) { $fd = fopen($this->compile_dir."/valid.html","w"); fwrite($fd, $result); diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 77dd994..c74a0d6 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -180,8 +180,8 @@ function getNbNotifs() // selectionne les notifs de uid, sans detail sur le watcher, depuis // $watchlast, meme ceux sans surveillance, non ordonnés - $res = XDB::query(_select_notifs_count('contacts') . ' UNION DISTINCT ' - . _select_notifs_count('watch_promo') . ' UNION DISTINCT ' + $res = XDB::query(_select_notifs_count('contacts') . ' UNION ' + . _select_notifs_count('watch_promo') . ' UNION ' . _select_notifs_count('watch_nonins'), $uid, $uid, $uid); $n = array_sum($res->fetchColumn()); if ($n == 0) { diff --git a/templates/skin/common.backtrace.tpl b/templates/skin/common.backtrace.tpl index 436e923..2e29454 100644 --- a/templates/skin/common.backtrace.tpl +++ b/templates/skin/common.backtrace.tpl @@ -20,7 +20,14 @@ {* *} {**************************************************************************} - +{foreach from=$backtraces key=bt_name item=trace} +
+

+ {if $trace->error}{/if} + Exécution de {$bt_name} : {$trace->traces|@count} actions en {$trace->totaltime|string_format:"%.3f"}s (hover-me pour la trace) + {if $trace->error}{/if} +

+
{foreach item=query from=$trace->traces} {if $query.data} {assign var=cols value=$query.data[0]|@count} @@ -66,5 +73,8 @@ {/if} {/foreach} +
+
+{/foreach} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/skin/common.devel.tpl b/templates/skin/common.devel.tpl index 22f6b07..868f138 100644 --- a/templates/skin/common.devel.tpl +++ b/templates/skin/common.devel.tpl @@ -21,18 +21,7 @@ {**************************************************************************} {if #globals.debug#} -{foreach from=$backtraces key=bt_name item=trace} -
-

- {if $trace->error}{/if} - Exécution de {$bt_name} : {$trace->traces|@count} actions en {$trace->totaltime|string_format:"%.3f"}s (hover-me pour la trace) - {if $trace->error}{/if} -

-
- {include file="skin/common.backtrace.tpl"} -
-
-{/foreach} +@@BACKTRACE@@ {if $validate}
-- 2.1.4