From 697990b11d40eecd6b4b1ef677de5ea4ae3cea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pauli=20J=C3=A4rvinen?= Date: Sat, 16 Mar 2024 22:03:56 +0200 Subject: [PATCH] Fix error being logged on each played song with PHP 8.3 Don't try to set the response status again in case the file streaming has already successfully started. This has probably never made sense but prior to PHP 8.3 this was just silently ignored. refs https://github.com/owncloud/music/issues/1133 --- CHANGELOG.md | 2 ++ lib/Http/FileStreamResponse.php | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f06952df..73252e105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ [#1125](https://github.com/owncloud/music/pull/1125) @perillamint - Playlist file not playing within Files in case the first track of the list is in unsupported format - Some Finnish translations being replaced with English (since v1.9.0) +- Error "Cannot set response code - headers already sent" logged on each played song on PHP 8.3 + [#1133](https://github.com/owncloud/music/issues/1133) ## 1.10.0 - 2024-01-27 diff --git a/lib/Http/FileStreamResponse.php b/lib/Http/FileStreamResponse.php index 1a8d58a4d..a945f9e93 100644 --- a/lib/Http/FileStreamResponse.php +++ b/lib/Http/FileStreamResponse.php @@ -7,7 +7,7 @@ * later. See the COPYING file. * * @author Pauli Järvinen - * @copyright Pauli Järvinen 2021, 2022 + * @copyright Pauli Järvinen 2021 - 2024 */ namespace OCA\Music\Http; @@ -77,16 +77,14 @@ public function callback(IOutput $output) { $fp = $this->file->fopen('r') ?? null; if (!is_resource($fp)) { - $status = Http::STATUS_NOT_FOUND; + $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); } else { if ($this->streamDataToOutput($fp) === false) { - $status = Http::STATUS_BAD_REQUEST; + $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); } \fclose($fp); } } - - $output->setHttpResponseCode($status); } private function streamDataToOutput($fp) {