From 7990f95558ac2b7fac3b9f77dcbdc3c74b05785b Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sat, 10 Apr 2021 15:05:18 +0200 Subject: [PATCH] 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 --- lib/private/Files/View.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index a59f735c10..8f4b5db116 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -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