Give names to debug flags and add a new flag for smarty debugging:
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 30 Apr 2007 14:09:00 +0000 (14:09 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 30 Apr 2007 14:09:00 +0000 (14:09 +0000)
-> 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
classes/platalpage.php
classes/xdb.php
include/banana/forum.inc.php
include/banana/ml.inc.php
include/banana/moderate.inc.php
include/platal.inc.php

index 63fec4d..b70fcbf 100644 (file)
@@ -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');
         }   
     }
index 096c39d..57e112f 100644 (file)
@@ -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<br />', microtime(true) - $TIME_BEGIN
                                                                                 , memory_get_peak_usage(true) / 1024);
         $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
 
-        if ($globals->debug & 2) {
+        if ($globals->debug & DEBUG_VALID) {
             $fd = fopen($this->compile_dir."/valid.html","w");
             fwrite($fd, $result);
             fclose($fd);
index da211a0..502af95 100644 (file)
@@ -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);
index 9dc0291..aa81865 100644 (file)
@@ -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;
         }
index 60d2fee..4880a53 100644 (file)
@@ -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';
index d597fc2..76ca291 100644 (file)
@@ -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');
     }
index bab48ad..c630913 100644 (file)
@@ -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);