Skip to content

Commit

Permalink
Subsonic + sql bug fixes, dsub workaround
Browse files Browse the repository at this point in the history
* decade search
* genre search
* sql bug in Tag::get_tag_objects
* Dsub has fromyear and toyear backwards. (test which is larger.)
* Force subsonic to report highest version supported (1.13.0)
  • Loading branch information
lachlan-00 committed Sep 26, 2019
1 parent e7f79ac commit 74c0b83
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ vendor/
core/
develop/
master/
*.swp
4 changes: 2 additions & 2 deletions lib/class/subsonic_api.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ public static function getalbumlist($input, $elementName = "albumList")
$albums = Catalog::get_albums_by_artist($size, $offset, $catalogs);
break;
case "byYear":
$fromYear = $input['fromYear'];
$toYear = $input['toYear'];
$fromYear = $input['fromYear'] < $input['toYear'] ? $input['fromYear']: $input['toYear'] ;
$toYear = $input['toYear'] > $input['fromYear'] ? $input['toYear'] : $input['fromYear'];

if ($fromYear || $toYear) {
$search = Search::year_search($fromYear, $toYear, $size, $offset);
Expand Down
8 changes: 2 additions & 6 deletions lib/class/subsonic_xml_data.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ public static function getAmpacheType($objectid)

public static function createFailedResponse($version = '', $function = '')
{
if (empty($version)) {
$version = self::API_VERSION;
}
$version = self::API_VERSION;
$response = self::createResponse($version, 'failed');
debug_event('subsonic_xml_data.class', 'API fail in function ' . $function . '-' . $version, 3);

Expand All @@ -227,9 +225,7 @@ public static function createFailedResponse($version = '', $function = '')

public static function createSuccessResponse($version = '', $function = '')
{
if (empty($version)) {
$version = self::API_VERSION;
}
$version = self::API_VERSION;
$response = self::createResponse($version);
debug_event('subsonic_xml_data.class', 'API success in function ' . $function . '-' . $version, 5);

Expand Down
6 changes: 3 additions & 3 deletions lib/class/tag.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,17 @@ public static function get_tag_objects($type, $tag_id, $count = '', $offset = ''

$limit_sql = "";
if ($count) {
$limit_sql = "LIMIT ";
$limit_sql = " LIMIT ";
if ($offset) {
$limit_sql .= (string) ($offset) . ', ';
}
$limit_sql .= (string) ($count);
}

$sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " .
"WHERE `tag_map`.`tag_id` = ? AND `tag_map`.`object_type` = ? $limit_sql ";
"WHERE `tag_map`.`tag_id` = ? AND `tag_map`.`object_type` = ? ";
if (AmpConfig::get('catalog_disable')) {
$sql .= "AND " . Catalog::get_enable_filter($type, '`tag_map`.`object_id`');
$sql .= "AND " . Catalog::get_enable_filter($type, '`tag_map`.`object_id`') . $limit_sql;
}
$db_results = Dba::read($sql, array($tag_id, $type));

Expand Down

0 comments on commit 74c0b83

Please sign in to comment.