From 81e9c63f59b2f7040556d4f9232462e25a3d9f57 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Mon, 30 Apr 2007 14:09:00 +0000 Subject: [PATCH] Give names to debug flags and add a new flag for smarty debugging: -> DEBUG_BT = 1, show mysql/banana/rpc backtrace -> DEBUG_VALID = 2, validate xhtml -> DEBUG_SMARTY = 4 = show smarty errors classes/mmlist.php | 2 +- classes/platalpage.php | 12 ++++++++---- classes/xdb.php | 6 +++--- include/banana/forum.inc.php | 3 ++- include/banana/ml.inc.php | 3 ++- include/banana/moderate.inc.php | 1 + include/platal.inc.php | 4 ++++ 7 files changed, 21 insertions(+), 10 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1781 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/mmlist.php | 2 +- classes/platalpage.php | 12 ++++++++---- classes/xdb.php | 6 +++--- include/banana/forum.inc.php | 3 ++- include/banana/ml.inc.php | 3 ++- include/banana/moderate.inc.php | 1 + include/platal.inc.php | 4 ++++ 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/classes/mmlist.php b/classes/mmlist.php index 63fec4d..b70fcbf 100644 --- a/classes/mmlist.php +++ b/classes/mmlist.php @@ -28,7 +28,7 @@ class MMList extends XmlrpcClient $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn; $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom"; parent::__construct($url); - if ($globals->debug & 1) { + if ($globals->debug & DEBUG_BT) { $this->bt = new PlBacktrace('MMList'); } } diff --git a/classes/platalpage.php b/classes/platalpage.php index 096c39d..57e112f 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -106,7 +106,9 @@ abstract class PlatalPage extends Smarty switch ($this->_page_type) { case NO_SKIN: - error_reporting(0); + if (!($globals->debug & DEBUG_SMARTY)) { + error_reporting(0); + } $this->display($this->_tpl); exit; @@ -130,19 +132,21 @@ abstract class PlatalPage extends Smarty exit; } - if ($globals->debug & 1) { + if ($globals->debug & DEBUG_BT) { PlBacktrace::clean(); $this->assign_by_ref('backtraces', PlBacktrace::$bt); } $this->assign('validate', true); - error_reporting(0); + if (!($globals->debug & DEBUG_SMARTY)) { + error_reporting(0); + } $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 & 2) { + if ($globals->debug & DEBUG_VALID) { $fd = fopen($this->compile_dir."/valid.html","w"); fwrite($fd, $result); fclose($fd); diff --git a/classes/xdb.php b/classes/xdb.php index da211a0..502af95 100644 --- a/classes/xdb.php +++ b/classes/xdb.php @@ -27,7 +27,7 @@ class XDB { global $globals; XDB::$mysqli = new mysqli($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb); - if ($globals->debug & 1) { + if ($globals->debug & DEBUG_BT) { $bt = new PlBacktrace('MySQL'); if (mysqli_connect_errno()) { $bt->newEvent("MySQLI connection", 0, mysqli_connect_error()); @@ -79,7 +79,7 @@ class XDB return false; } - if ($globals->debug & 1) { + if ($globals->debug & DEBUG_BT) { $explain = array(); if (strpos($query, 'FOUND_ROWS()') === false) { $res = XDB::$mysqli->query("EXPLAIN $query"); @@ -95,7 +95,7 @@ class XDB $res = XDB::$mysqli->query($query); - if ($globals->debug & 1) { + if ($globals->debug & DEBUG_BT) { PlBacktrace::$bt['MySQL']->stop(@$res->num_rows ? $res->num_rows : XDB::$mysqli->affected_rows, XDB::$mysqli->error, $explain); diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 9dc0291..aa81865 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -44,7 +44,8 @@ class ForumsBanana extends Banana if (S::has_perms()) { Banana::$msgshow_mimeparts[] = 'source'; } - Banana::$debug_nntp = ($globals->debug & 1); + Banana::$debug_nntp = ($globals->debug & DEBUG_BT); + Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); if (!S::v('core_rss_hash')) { Banana::$feed_active = false; } diff --git a/include/banana/ml.inc.php b/include/banana/ml.inc.php index 60d2fee..4880a53 100644 --- a/include/banana/ml.inc.php +++ b/include/banana/ml.inc.php @@ -33,7 +33,8 @@ class MLBanana extends Banana Banana::$spool_root = $globals->banana->spool_root; Banana::$spool_boxlist = false; Banana::$msgedit_canattach = true; - Banana::$debug_mbox = ($globals->debug & 1); + Banana::$debug_mbox = ($globals->debug & DEBUG_BT); + Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); Banana::$mbox_helper = $globals->banana->mbox_helper; if (S::has_perms()) { Banana::$msgshow_mimeparts[] = 'source'; diff --git a/include/banana/moderate.inc.php b/include/banana/moderate.inc.php index d597fc2..76ca291 100644 --- a/include/banana/moderate.inc.php +++ b/include/banana/moderate.inc.php @@ -70,6 +70,7 @@ class ModerationBanana extends Banana Banana::$msgshow_externalimages = false; Banana::$msgshow_mimeparts[] = 'source'; Banana::$feed_active = false; + Banana::$debug_smarty = ($globals->debug & DEBUG_SMARTY); array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail'); parent::__construct($params, 'MLInterface', 'ModerationPage'); } diff --git a/include/platal.inc.php b/include/platal.inc.php index bab48ad..c630913 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -36,6 +36,10 @@ define('NO_SKIN', 2); define('NO_AUTH', 0); define('DO_AUTH', 1); +define('DEBUG_BT', 1); +define('DEBUG_VALID', 2); +define('DEBUG_SMARTY', 4); + function __autoload($cls) { $cls = strtolower($cls); -- 2.1.4