NOBUG standardising prevention of output buffering
[moodle.git] / admin / report / unittest / index.php
index 814ceab..c576899 100644 (file)
@@ -15,6 +15,20 @@ require_once($CFG->libdir.'/simpletestcoveragelib.php');
 require_once('ex_simple_test.php');
 require_once('ex_reporter.php');
 
+// disable compression, it would prevent closing of buffers
+if (ini_get('zlib.output_compression')) {
+    ini_set('zlib.output_compression', 'Off');
+}
+
+// try to flush everything all the time
+ob_implicit_flush(true);
+while(ob_get_level()) {
+    if (!ob_end_clean()) {
+        // prevent infinite loop
+        break;
+    }
+}
+
 // Always run the unit tests in developer debug mode.
 $CFG->debug = DEBUG_DEVELOPER;
 error_reporting($CFG->debug);