diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25b67455d70..e7a80627636 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8923,6 +8923,7 @@ function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, /** * Return a file on output using a lo memory. * It can return very large files with no need of memory. + * WARNING: This close output buffers. * * @param string $fullpath_original_file_osencoded Full path of file to return. * @param int $method -1 automatic, 0=readfile, 1=fread, 2=stream_copy_to_stream @@ -8937,11 +8938,11 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) if (! empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) $method = 2; } + // Be sure we don't have output buffering enabled to have readfile working correctly + while (ob_get_level()) ob_end_flush(); + // Solution 0 if ($method == 0) { - // Be sure we don't have output buffering enabled to have readfile working correctly - while (ob_get_level()) ob_end_flush(); - readfile($fullpath_original_file_osencoded); } // Solution 1