gunnar: server/php-kolab/Kolab_Filter/Filter Filter.php, 1.3, 1.4 Incoming.php, 1.4, 1.5 Outgoing.php, 1.4, 1.5 Resource.php, 1.2, 1.3

cvs at kolab.org cvs at kolab.org
Tue Nov 27 15:21:17 CET 2007


Author: gunnar

Update of /kolabrepository/server/php-kolab/Kolab_Filter/Filter
In directory doto:/tmp/cvs-serv15180/php-kolab/Kolab_Filter/Filter

Modified Files:
	Filter.php Incoming.php Outgoing.php Resource.php 
Log Message:
kolab/issue2177 (Better logging in kolabfilter and kolabmailboxfilter)

Index: Filter.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Filter/Filter/Filter.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Filter.php	27 Nov 2007 12:35:23 -0000	1.3
+++ Filter.php	27 Nov 2007 14:21:15 -0000	1.4
@@ -68,6 +68,8 @@
 
     var $_startts;
 
+    var $_id = '';
+
     var $_debug;
 
     var $_tmpdir;
@@ -85,6 +87,21 @@
     {
         global $conf;
 
+        /* Always display all possible problems */
+        ini_set('error_reporting', E_ALL);
+        ini_set('track_errors', '1');
+
+        /* Setup error logging */
+        if (!empty($conf['filter']['error_log'])) {
+            ini_set('log_errors', '1');
+            ini_set('error_log', $conf['filter']['error_log']);
+        }
+
+        /* Print PHP messages to StdOut if we are debugging */
+        if ($debug) {
+            ini_set('display_errors', '1');
+        }
+
         $this->_transport = $transport;
         $this->_debug = $debug;
 
@@ -138,6 +155,12 @@
         if ($result instanceof PEAR_Error) {
             $this->_handle($result);
         }
+
+        Horde::logMessage(sprintf(_("%s successfully completed (sender=%s, recipients=%s, client_address=%s, id=%s)"), 
+                                  get_class($this), $this->_sender, 
+                                  join(', ',$this->_recipients), 
+                                  $this->_client_address, $this->_id),
+                          __FILE__, __LINE__, PEAR_LOG_INFO);
     }
     
     function _start()
@@ -155,7 +178,9 @@
         }
 
         Horde::logMessage(sprintf(_("%s starting up (sender=%s, recipients=%s, client_address=%s)"), 
-                                  get_class($this), $this->_sender, join(', ',$this->_recipients), $this->_client_address),
+                                  get_class($this), $this->_sender, 
+                                  join(', ',$this->_recipients), 
+                                  $this->_client_address),
                           __FILE__, __LINE__, PEAR_LOG_DEBUG);
     }
     
@@ -169,14 +194,18 @@
         $args = $_SERVER['argv'];
         $opts = array( 's', 'r', 'c', 'h', 'u' );
 
+        Horde::logMessage(sprintf(_("Arguments: %s"), print_r($args, true)),
+                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+
         $options = array();
         for ($i = 0; $i < count($args); ++$i) {
             $arg = $args[$i];
-            if ($arg[0] == '-') {
+            if (!empty($arg) && $arg[0] == '-' && isset($arg[1])) {
                 if (in_array($arg[1], $opts)) {
                     $val = array();
                     $i++;
-                    while($i < count($args) && $args[$i][0] != '-') {
+                    while($i < count($args) && !empty($args[$i]) && 
+                          $args[$i][0] != '-') {
                         $val[] = $args[$i];
                         $i++;
                     }
@@ -302,21 +331,24 @@
             $msg = 'CRITICAL: You hit a fatal bug in kolab-filter. Please inform the Kolab developers at https://www.intevation.de/roundup/kolab/. The error was: ' . $errmsg;
         } else {
             $code = 0;
-            $msg = $errmsg;
+            $msg = 'PHP Error: ' . $errmsg;
         }
 
         $error = &new PEAR_Error($msg, $code);
         $this->_handle($error);
 
-        if ($errno == E_ERROR) {
-            exit(0);
-        }
         return false;
     }
 
     function _log($result)
     {
-        $msg = $result->getMessage();
+        if (!empty($this->_id)) {
+            $id = ' <ID: ' . $this->_id . '>';
+        } else {
+            $id = '';
+        }
+            
+        $msg = $result->getMessage() . $id;
 
         /* Log all errors */
         $frame = $result->getBacktrace(1);
@@ -325,7 +357,7 @@
          * without a time stamp (mainly because of unit testint) 
          */
         if (!$this->_debug) {
-            Horde::logMessage($msg, $frame['file'], $frame['line']);
+            Horde::logMessage($msg, $frame['file'], $frame['line'], PEAR_LOG_ERR);
         } else {
             $msg .= ' (Line ' . $frame['line'] . ' in ' . basename($frame['file']) . ")\n";
             fwrite(STDOUT, $msg);

Index: Incoming.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Filter/Filter/Incoming.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Incoming.php	27 Nov 2007 12:35:23 -0000	1.4
+++ Incoming.php	27 Nov 2007 14:21:15 -0000	1.5
@@ -58,10 +58,12 @@
             if ($line == '') {
                 /* Done with headers */
                 $headers_done = true;
-            } else if(eregi('^Content-Type: text/calendar', $line)) {
+            } else if (eregi('^Content-Type: text/calendar', $line)) {
                 Horde::logMessage(_("Found iCal data in message"), 
                                   __FILE__, __LINE__, PEAR_LOG_DEBUG);
                 $ical = true;
+            } else if (eregi('^Message-ID: (.*)', $line, $regs)) {
+                $this->_id = $regs[1];
             }
             if (@fwrite($this->_tmpfh, $buffer) === false) {
                 $msg = $php_errormsg;
@@ -100,9 +102,7 @@
                                     $this->_tmpfile);
 
                 if (is_a($rc, 'PEAR_Error')) {
-                    fwrite(STDOUT, sprintf(_("Filter failed: %s\n"),
-                                           $rc->getMessage()));
-                    exit(EX_TEMPFAIL);
+                    return $rc;
                 } else if ($rc === true) {
                     $newrecips[] = $recip;
                 }

Index: Outgoing.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Filter/Filter/Outgoing.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Outgoing.php	27 Nov 2007 12:35:23 -0000	1.4
+++ Outgoing.php	27 Nov 2007 14:21:15 -0000	1.5
@@ -125,6 +125,8 @@
                         Horde::logMessage(_("Found iCal data in message"),
                                           __FILE__, __LINE__, PEAR_LOG_DEBUG);
                         $ical = true;
+                    } else if (eregi('^Message-ID: (.*)', $line, $regs)) {
+                        $this->_id = $regs[1];
                     }
                     break;
                 case RM_STATE_READING_FROM:
@@ -183,9 +185,6 @@
         if (is_a($result, 'PEAR_Error')) {
             return $result;
         }
-        
-        Horde::logMessage(_("Filter_Outgoing successfully completed."), 
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
     }
 
     function deliver($rewrittenfrom)

Index: Resource.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Filter/Filter/Resource.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Resource.php	27 Nov 2007 10:01:52 -0000	1.2
+++ Resource.php	27 Nov 2007 14:21:15 -0000	1.3
@@ -882,28 +882,21 @@
     return $epoch;
 }
 
-function &buildKolabEvent(&$itip, $use_new_horde)
+function &buildKolabEvent(&$itip)
 {
     global $organiser, $resource, $uid, $sid;
 
-    if (version_compare(PHP_VERSION,'5', '>=') && !$use_new_horde) {
-        require_once('Kolab/Freebusy/domxml-php4-to-php5.php');
-    } else {
-        require_once('Horde/DOM.php');
-    }
+    require_once('Horde/DOM.php');
 
     $recurrence = false;
-    if (!$use_new_horde) {
-        $kolab_xml = domxml_new_doc('1.0');
-    } else {
-        $kolab_xml = Horde_DOM_Document::factory(array('xml' => $xml_text));
-        if (is_a($result, 'PEAR_Error')) {
-            // There were errors building the xml document
-            Horde::logMessage(sprintf(_("Error building xml document: %s"), 
-                                      $result->getMessage()),
-                __FILE__, __LINE__, PEAR_LOG_ERR);
-            return false;
-        }
+
+    $kolab_xml = Horde_DOM_Document::factory(array('xml' => $xml_text));
+    if (is_a($result, 'PEAR_Error')) {
+        // There were errors building the xml document
+        Horde::logMessage(sprintf(_("Error building xml document: %s"), 
+                                  $result->getMessage()),
+                          __FILE__, __LINE__, PEAR_LOG_ERR);
+        return false;
     }
     
     $kolab_event = $kolab_xml->append_child($kolab_xml->create_element('event'));





More information about the commits mailing list