Skip to content

Commit

Permalink
Fix error being logged on each played song with PHP 8.3
Browse files Browse the repository at this point in the history
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 #1133
  • Loading branch information
paulijar committed Mar 16, 2024
1 parent 6c5057c commit 697990b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions lib/Http/FileStreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* later. See the COPYING file.
*
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Pauli Järvinen 2021, 2022
* @copyright Pauli Järvinen 2021 - 2024
*/

namespace OCA\Music\Http;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 697990b

Please sign in to comment.