Skip to content

Commit

Permalink
Subsonic: Fix getPlaylist breaking if the list has any invalid tracks
Browse files Browse the repository at this point in the history
Also, set non-null values for some of the fields of the returned broken
track as the Ultrasonic client doesn't seem to tolerate null values on
all fields.

refs #853
  • Loading branch information
paulijar committed May 6, 2021
1 parent 34da573 commit eae36b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

### Fixed
- Details icon not being shown after a truncated album title in the Albums view
- Errors being spammed to the log on NC18+ with PHP older than 7.4 when config.php has `'debug' => true`
[#849](https://github.com/owncloud/music/issues/849)
- Subsonic method `getPlaylist` breaking if the list has any invalid tracks
[#853](https://github.com/owncloud/music/issues/853)

## 1.1.0 - 2021-03-24
### Added
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/SubsonicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ private function trackToApi($track) {
$albumId = $track->getAlbumId();

$album = $track->getAlbum();
if (empty($album)) {
if ($album === null && $albumId !== null) {
$album = $this->albumBusinessLayer->findOrDefault($albumId, $this->userId);
$track->setAlbum($album);
}
Expand All @@ -1131,13 +1131,13 @@ private function trackToApi($track) {
'id' => 'track-' . $track->getId(),
'parent' => 'album-' . $albumId,
//'discNumber' => $track->getDisk(), // not supported on any of the tested clients => adjust track number instead
'title' => $track->getTitle(),
'title' => $track->getTitle() ?? '',
'artist' => $track->getArtistNameString($this->l10n),
'isDir' => false,
'album' => $track->getAlbumNameString($this->l10n),
'year' => $track->getYear(),
'size' => $track->getSize(),
'contentType' => $track->getMimetype(),
'size' => $track->getSize() ?? 0,
'contentType' => $track->getMimetype() ?? '',
'suffix' => $track->getFileExtension(),
'duration' => $track->getLength() ?: 0,
'bitRate' => \round($track->getBitrate()/1000) ?: 0, // convert bps to kbps
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Track.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getAdjustedTrackNumber() {
}

public function getFileExtension() {
$parts = \explode('.', $this->getFilename());
$parts = \explode('.', $this->getFilename() ?? '');
return \end($parts);
}

Expand Down

0 comments on commit eae36b8

Please # to comment.