Skip to content

Commit

Permalink
Ampache: Return all results if argument limit=0 given
Browse files Browse the repository at this point in the history
This is how the "real" Ampache server works, too, although this is not
documented in the current API specification for v4 or v5 API. The Amarok
player uses this argument value, and there should be no real-life case where
the client actually would want to have 0 interpreted as literal value of the
limit.

Furthermore, the Music app already tried to interpret zero as "unlimited" but
this worked only with integer 0 and not with string "0". Whether the numeric
arguments come as strings or integers, depends on the details of the hosting
cloud, and may differ between versions of ownCloud and Nextcloud.

refs #854
  • Loading branch information
paulijar committed May 8, 2021
1 parent eae36b8 commit 70d3afe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
[#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)
- Ampache methods returning empty result sets to Amarok which passes (invalid) argument `limit=0`
[#854](https://github.com/owncloud/music/issues/854)

## 1.1.0 - 2021-03-24
### Added
Expand Down
9 changes: 3 additions & 6 deletions lib/Controller/AmpacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Morris Jobke <hey@morrisjobke.de>
* @author Pauli Järvinen <pauli.jarvinen@gmail.com>
* @copyright Morris Jobke 2013, 2014
* @copyright Pauli Järvinen 2017 - 2020
* @copyright Pauli Järvinen 2017 - 2021
*/

namespace OCA\Music\Controller;
Expand Down Expand Up @@ -881,11 +881,8 @@ private function createCoverUrl($entity, $auth) {
* @return integer|null
*/
private static function validateLimitOrOffset($value) : ?int {
if (\ctype_digit(\strval($value)) && $value !== 0) {
return \intval($value);
} else {
return null;
}
$value = (int)$value;
return ($value > 0) ? $value : null;
}

/**
Expand Down

0 comments on commit 70d3afe

Please sign in to comment.