diff --git a/htdocs/always.php b/htdocs/always.php index 1bdd81ac..1ef6d6b6 100644 --- a/htdocs/always.php +++ b/htdocs/always.php @@ -26,7 +26,10 @@ function early_exception_handler($e) { echo "
\n";
     // Too late to set resultcode :-(
   }
-  while ( ob_get_level() > 0 ) ob_end_flush();
+  try {
+    @ob_flush(); // Seems like it should be better to do the following but is problematic on PHP5.3 at least: while ( ob_get_level() > 0 ) ob_end_flush();
+  }
+  catch( Exception $ignored ) {}
   echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
   echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
   echo "================= Stack Trace ===================\n";
diff --git a/htdocs/setup.php b/htdocs/setup.php
index c4fda678..9adb3fd2 100644
--- a/htdocs/setup.php
+++ b/htdocs/setup.php
@@ -30,7 +30,10 @@ function catch_setup_errors($errno , $errstr , $errfile , $errline , $errcontext
     return true;
   }
   if ( !headers_sent() ) header("Content-type: text/plain"); else echo "
\n";
-  while ( ob_get_level() > 0 ) ob_end_flush();
+  try {
+    @ob_flush(); // Seems like it should be better to do the following but is problematic on PHP5.3 at least: while ( ob_get_level() > 0 ) ob_end_flush();
+  }
+  catch( Exception $ignored ) {}
   echo "Error [".$errno."] ".$errstr."\n";
   echo "At line ", $errline, " of ", $errfile, "\n";
 
diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php
index 624a32bc..92838995 100644
--- a/inc/CalDAVRequest.php
+++ b/inc/CalDAVRequest.php
@@ -1294,7 +1294,11 @@ EOSQL;
       @dbg_error_log("statistics", "Method: %s, Status: %d, Script: %5.3lfs, Queries: %5.3lfs, URL: %s",
                          $this->method, $status, $script_time, $c->total_query_time, $this->path);
     }
-    while ( ob_get_level() > 0 ) ob_end_flush();
+    try {
+      @ob_flush(); // Seems like it should be better to do the following but is problematic on PHP5.3 at least: while ( ob_get_level() > 0 ) ob_end_flush();
+    }
+    catch( Exception $ignored ) {}
+    
     exit(0);
   }
 
diff --git a/inc/always.php.in b/inc/always.php.in
index f0a67616..6b455ac6 100644
--- a/inc/always.php.in
+++ b/inc/always.php.in
@@ -26,7 +26,10 @@ function early_exception_handler($e) {
     echo "
\n";
     // Too late to set resultcode :-(
   }
-  while ( ob_get_level() > 0 ) ob_end_flush();
+  try {
+    @ob_flush(); // Seems like it should be better to do the following but is problematic on PHP5.3 at least: while ( ob_get_level() > 0 ) ob_end_flush();
+  }
+  catch( Exception $ignored ) {}
   echo "Exception [".$e->getCode()."] ".$e->getmessage()."\n";
   echo "At line ", $e->getLine(), " of ", $e->getFile(), "\n";
   echo "================= Stack Trace ===================\n";