improves HTTP Server exception handling
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 30 Dec 2014 11:17:22 +0000 (12:17 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 30 Dec 2014 11:44:19 +0000 (12:44 +0100)
* return 500 error code if some error occurs during download or export
* adds a TODO in Calendar ods export test

Change-Id: I2d03e45397ab32557dc037838be550bc11556218
Reviewed-on: http://gerrit.tine20.com/customers/1492
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Export/OdsTests.php
tine20/Tinebase/Frontend/Http/Abstract.php
tine20/Tinebase/Server/Http.php

index 5eaa24a..3bca8a3 100644 (file)
@@ -14,6 +14,9 @@
  */
 class Calendar_Export_OdsTests extends Calendar_TestCase
 {
+    /**
+     * TODO add assertions
+     */
     public function testExportOds()
     {
         // export & check
index 63345d5..a471a9b 100644 (file)
@@ -57,7 +57,7 @@ abstract class Tinebase_Frontend_Http_Abstract extends Tinebase_Frontend_Abstrac
                         Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $_filter->getModelName() . ' id empty!');
                     }
                 }
-                    
+                
                 // render pdf
                 try {
                     $pdfOutput = $export->render();
index 9df99d4..65bfcd9 100644 (file)
@@ -86,17 +86,22 @@ class Tinebase_Server_Http extends Tinebase_Server_Abstract implements Tinebase_
             Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ .' Attempt to request a privileged Http-API method without valid session from "' . $_SERVER['REMOTE_ADDR']);
             
             header('HTTP/1.0 403 Forbidden');
-
             exit;
             
         } catch (Exception $exception) {
-            Tinebase_Exception::log($exception);
+            Tinebase_Exception::log($exception, false);
             
             try {
                 $setupController = Setup_Controller::getInstance();
                 if ($setupController->setupRequired()) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' Setup required');
                     $this->_method = 'Tinebase.setupRequired';
+                } else if (preg_match('/download|export/', $this->_method)) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' Server error during download/export - exit with 500');
+                    header('HTTP/1.0 500 Internal Server Error');
+                    exit;
                 } else {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' Show mainscreen with setup exception');
                     $this->_method = 'Tinebase.exception';
                 }