Check whether output buffering is active before turning it off

Before we just turned it off and @suppressed the error if ob was not active.
In PHP 8 this error is no longer suppressed, so try to not cause it at all.

Signed-off-by: Richard de Boer <git@tubul.net>
This commit is contained in:
Richard de Boer 2021-04-10 15:05:18 +02:00 committed by Richard de Boer
parent a0d265b0b1
commit 7990f95558
1 changed files with 6 additions and 2 deletions

View File

@ -422,7 +422,9 @@ class View {
*/
public function readfile($path) {
$this->assertPathLength($path);
@ob_end_clean();
if (ob_get_level()) {
ob_end_clean();
}
$handle = $this->fopen($path, 'rb');
if ($handle) {
$chunkSize = 524288; // 512 kB chunks
@ -446,7 +448,9 @@ class View {
*/
public function readfilePart($path, $from, $to) {
$this->assertPathLength($path);
@ob_end_clean();
if (ob_get_level()) {
ob_end_clean();
}
$handle = $this->fopen($path, 'rb');
if ($handle) {
$chunkSize = 524288; // 512 kB chunks