Merged changes from main trunk up to 2.2.5
[fa-stable.git] / includes / errors.inc
index fc8f4fb692fca3205b277009755fd70291cf90df..551d32e4438a2c5b63f260d2e5adf84ac96be76d 100644 (file)
@@ -85,9 +85,9 @@ function error_box() {
     global $before_box;
     
     echo "<div id='msgbox'>";
-       $before_box = ob_get_clean(); // save html content before error box 
+
 // Necessary restart instead of get_contents/clean calls due to a bug in php 4.3.2
-       register_shutdown_function('end_flush');
+       $before_box = ob_get_clean(); // save html content before error box 
     ob_start('output_html');
     echo "</div>";
 }
@@ -99,8 +99,8 @@ function end_flush () {
 
        if (isset($Ajax))
                $Ajax->run();
-
-       if (ob_get_level()) ob_end_flush();
+       // flush all output buffers (works also with exit inside any div levels)
+       while(ob_get_level()) ob_end_flush();
 }
 
 function display_db_error($msg, $sql_statement=null, $exit=true)